1. Go to this page and download the library: Download mamadou-aly-sy/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/ */
mamadou-aly-sy / router example snippets
er = new \MamadouAlySy\Router(
new \MamadouAlySy\RouteCollection()
);
$router->get('/', function () {/**/});
$router->post('/', function () {/**/});
$router->put('/', function () {/**/});
$router->delete('/', function () {/**/});
$router->any('/', function () {/**/});
$route = $router->match('GET', '/'); // => returns a route if match or null if not match
$route->getName(); // => returns the route name
$route->getAction(); // => returns the route action
$route->getParameters(); // => returns the route matched parameters
$router->get('/user/:id', function () {/**/})->with('id', '[0-9]+');
$router->get('/:action/:name', function () {/**/});