Closed gmanricks closed 11 years ago
I added some new ways to add routes as per a comment left by ross on the NetTuts article. These changes are backwards compatible, and the old method will still work.
$routes = array( '/' => '', '/test/:title' => 'Main:test@get' );
This is from the comment on NetTuts, it is in-order that you can have multiple routes pointing to the same endpoint. (e.g. different methods)
$routes = array( array('/home', 'Main:displayhome@get'), array('/home', 'Main:addComment@post') );
This is a mix of the two, providing a slightly nicer syntax.
$routes = array( '/users' => array( 'get' => 'UsersController:displayUsers', 'post' => 'UsersController:addUser', 'delete' => 'UsersController:removeUser' ) );
And of course the 3 different options can be mixed and matched so your route array can look like:
$routes = array( '/' => '', '/test/:title' => "Main:test@get", array('/arr', "Main:index@get"), '/demo' => array( "get" => "Main:test2", "post" => "Main:test3" ) );
Hi guys! How to fetch request arguments in code?
My route:
$routes = array( '/page/:id' => 'Page:index@get' );
in controller
$this->request->get('id');
dosen't work?
New Route Adding Options
I added some new ways to add routes as per a comment left by ross on the NetTuts article. These changes are backwards compatible, and the old method will still work.
The Options:
1) Key - Value (The Original Way)
2) Array (Route, Action)
This is from the comment on NetTuts, it is in-order that you can have multiple routes pointing to the same endpoint. (e.g. different methods)
3) Key - Array
This is a mix of the two, providing a slightly nicer syntax.
And of course the 3 different options can be mixed and matched so your route array can look like: