iandenh/router

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (0.2) of this package.

A simple PHP router

0.2 2014-01-07 08:53 UTC

This package is auto-updated.

Last update: 2022-02-01 12:29:06 UTC


README

Router.php is a simple Router for PHP.

Example

<?php
require_once 'src/Router/Router.php';
require_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';
});

Ian den Hartog