1. Go to this page and download the library: Download pyrsmk/lumy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pyrsmk / lumy example snippets
$lumy=new Lumy\Http;
// Add a middleware to configure our template engine (with [Twig](http://twig.sensiolabs.org/))
$lumy->middleware(function($middlewares) use($lumy){
$lumy['twig']=new Twig_Environment(
new Twig_Loader_Filesystem($lumy['dirs']['templates']),
$options
);
$middlewares->next();
});
// Add a basic route that do nothing but display our index page
$lumy->get('/',function() use($lumy){
// Provide a rooturi variable to the template is really useful for CSS, images, scripts inclusion
echo $lumy['twig']->render('index.tpl',array(
'rooturi' => $lumy['environment']->getRootUri()
));
});
// Specify an error handler, throwed when an exception has been catched
$lumy->error(function($e) use($lumy){
echo $lumy['twig']->render('error.tpl',array(
'rooturi' => $lumy['environment']->getRootUri(),
'message' => $e->getMessage()
));
});
// Run the application and print the response body
echo $lumy->run();
$lumy=Lumy\Http::getInstance();
$lumy->route('--help',function(){
// Will print 'Some help' when the 'your_app --help' command is called
echo 'Some help';
});
$lumy->route('install {directory}',function($directory){
// Some actions
});
$lumy->route('remove user {id}',function($id){
// Some actions
},array(
'directory' => '\d+'
));
// The 'show' command will show tables by default
$lumy->route('show {arg}',function($arg){
// Some actions
},array(
'arg' => 'databases|tables'
),array(
'arg' => 'tables'
));
$lumy->get('/gallery',function(){
// Display the gallery
});
$lumy->put('/gallery',function(){
// Add a new picture
});
$lumy->delete('/gallery/{id}',function($id){
// Delete the specified picture
});
$lumy->map('SEARCH','/gallery/{terms}',function($terms){
// Display the gallery
});
$lumy->get('%scheme%://{user}.mywebsite.com/profile',function($user){
// Show the requested user profile
},array(
'user' => '\w+'
));
// Name the route to register
$lumy->get('/gallery/{id}',function(){
// Some actions
},null,null,'gallery');
// ...
// Assemble an URL to
// Define the 'session' closure
$lumy['session']=function(){
return new Session();
};
// Set the closure as a service
$lumy->service('session');
// The Session object is ready
$lumy['session']['auth']=true;
$lumy->middleware(function($middlewares){
// Define our session service
$lumy['session']=function(){
return new Session();
};
$lumy->service('session');
// Call the next middleware
$middlewares->next();
// Clean up session when the application has been runned
unset($lumy['session']['cache']);
});
$lumy->error(function($exception){
// Print the encountered error
echo $exception->getMessage();
});
$lumy->run();
// The user will freely access to the files in images/, uploads/ and config/
$lumy->publish('/images');
$lumy->publish('/uploads');
$lumy->publish('/config');
// But he won't access to sensible data
$lumy->unpublish('/config/database.json');
// Add a 'gallery' route
$lumy->get('/gallery',function(){
// Some actions
},null,null,'gallery');
echo $lumy->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.