iandenh/router

A simple PHP router

Installs: 3

Dependents: 0

Stars: 5

Watchers: 2

Language: PHP

0.2 2014-01-07 08:53 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