dev-master
9999999-dev https://github.com/lemmon/routerLightweight standalone routing library for PHP
MIT
The Requires
- php >=7.0
by Jakub Pelak
boilerplate routing router sinatra
Wallogit.com
2017 © Pedro Peláez
Lightweight standalone routing library for PHP
Lemmon Router is a lightweight standalone routing library for PHP 7., (*1)
php composer.phar require lemmon/router
require 'vendor/autoload.php';
<?php
require_once __DIR__ . '/vendor/autoload.php';
$r = new Lemmon\Router\Router;
$r->match('hello-world', function() {
echo 'Hello World!';
});
$r->dispatch();
Example 1 - Respond to all requests, (*2)
$r->match(function() {
# matches everything
});
Example 2 - Match parameters, (*3)
$r->match('{controller}/{action}', function($r) {
# $r->controller;
# $r->action;
});
Example 3 - RESTful routing, (*4)
$r->match(['GET', 'PUT'], '{controller}(/(?<trail>{action:read|write}/{id:num:1,3=1})!)', ['controller' => '\w+'], function($r) {
# matches only GET and PUT requests
# matches either 'controller' or 'controller/action/id' when route conditions are met
# controller can be any word
# action is either read or write
# id must be numeric of length 1 to 3, default is 1
});
Lightweight standalone routing library for PHP
MIT
boilerplate routing router sinatra