3 A simple Rails inspired PHP router class.
5 * Usage of different HTTP Methods
6 * REST / Resourceful routing
7 * Reversed routing using named routes
8 * Dynamic URL's: use URL segments as parameters.
16 $router = new Router();
18 $router->setBasePath('/PHP-Router');
20 // defining routes can be as simple as this
21 $router->map('/', 'users#index');
23 // or somewhat more complicated
24 $router->map('/users/:id/edit/', array('controller' => 'SomeController', 'action' => 'someAction'), array('methods' => 'GET,PUT', 'name' => 'users_edit', 'filters' => array('id' => '(\d+)')));
26 // You can even specify closures as the Route's target
27 $router->map('/hello/:name', function($name) { echo "Hello $name."; });
29 // match current request URL & http method
30 $target = $router->matchCurrentRequest();
34 $router->generate('users_edit', array('id' => 5));
38 Have a look at the example.php file or read trough the class' documentation for a better understanding on how to use this class.
40 If you like PHP Router you might also like [AltoRouter](//github.com/dannyvankooten/AltoRouter).
43 MIT Licensed, http://www.opensource.org/licenses/MIT