1. Go to this page and download the library: Download hypario/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/ */
hypario / router example snippets
$router = new Hypario\Router(); // Here no parameters needed
$router->get('/', function () { echo "Hello World"; }); // Define a route in GET method.
$router = new Hypario\Router();
$router->post('/', function () { echo "Route accessed via POST method"; });
$router = new Hypario\Router();
$router->get('/', function () { echo "Hello World"; });
$route = $router->match($_SERVER['REQUEST_URI']);
$router = new Hypario\Router();
$router->get('/', function () { echo "Hello World"; });
$route = $router->match($_SERVER['REQUEST_URI']); // We get the matched route
if (!is_null($route)) {
$function = $route->getHandler(); // We get the function
call_user_func($function); // We call the function of the matched route
}