1 # Simple PHP Router class
3 A simple Router class that supports REST routing, named routes and reverse routing.
12 // maps / to controller 'users' and method 'index'.
13 $r->match('/','users#index');
15 // maps /user/5 to controller 'users', method 'show' with parameter 'id' => 5
16 $r->match('/user/:id','users#show');
18 // maps POST request to /users/ to controller 'users' and method 'create'
19 $r->match('/users','users#create',array('via' => 'post'));
22 // maps /users/5/edit to controller 'users', method 'edit' with parameters 'id' => 5.
23 $r->match('/user/:id/edit','users#edit',array('via' => 'get', 'as' => 'user_edit_page'));
25 // echoes /users/5/edit
26 echo $r->url_for_route('user_edit_page',array('id' => '5'));
30 extract($r->getRoute());
33 <p><b>Controller: </b><?php echo $controller; ?></p>
34 <p><b>Action: </b><?php echo $action; ?></p>
35 <p><b>Params: </b><?php var_dump($params); ?></p>
38 ?><h1>No route found.</h1><?php
41 Have a look at example.php or read trough the class' documentation for a better understanding on how to use this class.