1. Go to this page and download the library: Download kittenphp/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/ */
kittenphp / router example snippets
kitten\component\router\RouteCollector;
use kitten\component\router\RouteTracker;
$url=$_SERVER['REQUEST_URI'];
//$url='/news';
$router= new RouteCollector();
$router->get('/','HomeController@index');
$router->get('/news','NewsController@index');
$tracker=new RouteTracker($router->getRouteNodes());
$result=$tracker->search($url,'GET');
if (is_null($result)){
//No matching routes found
echo '404 Not Found';
}else{
$controller=$result->getRouteNode()->getCallable();
echo $controller; //Output: 'NewsController@index'
}