1. Go to this page and download the library: Download sdidev/router 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/ */
sdidev / router example snippets
// Require composer autoloader
uter = new \Bramus\Router\Router();
// Define routes
// ...
// Run it!
$router->run();
$router->mount('/movies', function() use ($router) {
// will result in '/movies/'
$router->get('/', function() {
echo 'movies overview';
});
// will result in '/movies/id'
$router->get('/(\d+)', function($id) {
echo 'movie id ' . htmlentities($id);
});
});
$router->set404(function() {
header('HTTP/1.1 404 Not Found');
// ... do something special here
});