PHP code example of bit55 / litero

1. Go to this page and download the library: Download bit55/litero 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/ */

    

bit55 / litero example snippets


$router = Bit55\Litero\Router::fromGlobals();

$router->add('/', function () {
    echo 'Hello from Litero!';
});

$router->add([
    '/first'       => 'Bit55\Litero\ExampleController@firstAction',
    '/second/:any'  => 'Bit55\Litero\ExampleController@secondAction',
]);

if ($router->isFound()) {
    $router->executeHandler(
        $router->getRequestHandler(),
        $router->getParams()
    );
} 
else {
    // Simple "Not found" handler
    $router->executeHandler(function () {
        http_response_code(404);
        echo '404 Not found';
    });
}