PHP code example of iandenh / router

1. Go to this page and download the library: Download iandenh/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/ */

    

iandenh / router example snippets



re_once 'src/Router/Route.php';

$router = new \Router\Router();

$router->add('GET','/', function(){
    echo 'index';
});
$router->add('/bar/*', function(){
    echo 'wildcard';
});
$router->add('/foo/:name', function($route){
    echo "Hallo, $route->name";
});
$router->add(new \Router\CaseInsensitiveRoute('/HaHa'), function($route){
    echo "Hallo, $route->name";
});
$router->route($_GET['q'], function(){
    echo 'error 404';
});