A simple PHP router
To use the router, you will need to rewrite all requests to a single file in which you create an instance of the router class.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
try_files $uri /index.php;
On the project folder run
php -S localhost:8080 -t ./example
$router = new Router();
$router->get('/xpto', function(){
echo 'Hello World';
});
$router->get('/xpto/{param}', function($param){
echo $param;
});
Add it on final of file
$router->listen();