1. Go to this page and download the library: Download dongnan/microrouter 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/ */
dongnan / microrouter example snippets
er = new \MicroRouter\Router();
$router->respond('GET', '/hello-world', function () {
return 'Hello World!';
});
$router->dispatch();
$router->respond('/hello-world', function () {
return 'Hello World!';
});
$router->respond('/[:name]', function ($params) {
return 'Hello ' . $params['name'];
});