A simple router in ~200 lines of PHP.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
composer.json

README.md

Traffic

A simple router in ~500 lines of PHP.

use Molovo\Traffic\Router;

Router::get('/hello', function() {
    echo 'Hello World!';
});

Installing

composer require "molovo/traffic"

Usage

// GET /news/2
Router::get('/news/{page:int}', function($page) {
    echo $page; // 2
});

// POST /user/hi@molovo.co
Router::get('/user/{email:email}', function($email) {
    echo $email; // hi@molovo.co
});

// Call execute once routes have been defined to
// execute the callback for the matching route.
Router::execute();