Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Added New Route Options as per Comment by ross #1
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.
1) Key - Value (The Original Way)
$routes = array( '/' => '', '/test/:title' => 'Main:test@get' );
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)
$routes = array( array('/home', 'Main:displayhome@get'), array('/home', 'Main:addComment@post') );
3) Key - Array
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" ) );