UrlRouter
in package
Simple URL Routing for "Old school" PHP apps
This is a simple router if you want to write an old-style PHP application but with decent looking URLs. It provides a simple alternative to building a full up Silex application.
Based on RegexRouter from https://github.com/moagrius/RegexRouter
Improvements:
- Add some "hot spots" {s} {d}
- Make it so "/" is relative to cwd
- Make it so the we add escapes and slashes to make the regex
Routing Rest URLs by pattern (Silex-Style)
$router = new Tsugi\Util\UrlRouter();
$router->route('/lessons/{s}$', function($id){
...
}
$router->execute();
Table of Contents
Properties
- $routes : mixed
Methods
- cwd() : mixed
- Gives the current folder of the executing script
- execute() : mixed
- route() : mixed
- trimQuery() : mixed
Properties
$routes
private
mixed
$routes
= array()
Methods
cwd()
Gives the current folder of the executing script
public
static cwd() : mixed
["SCRIPT_NAME"]=> string(21) "/wa4e/tsugi/route.php"
returns "/wa4e/tsugi" (no trailing slash)
execute()
public
execute(mixed $uri) : mixed
Parameters
- $uri : mixed
route()
public
route(mixed $pattern, mixed $callback) : mixed
Parameters
- $pattern : mixed
- $callback : mixed
trimQuery()
public
trimQuery([mixed $uri = null ]) : mixed
Parameters
- $uri : mixed = null