Suggestion: Easier Way to Manage Routes

I think for the next version of CodeIgniter should include an easier way to manage URI Routes. For example, I think it should be easier to organize your routes by controllers and controller directories, rather than just a huge route array. Here's an example of what I think the route array should look like:

//Example of a controller sub directory
$route['forums'] = array(
     'boards' => array(
          'edit/(:num)' => 'edit/$1', //Would create a route for the URI 'forums/boards/edit/123'
          '([a-z]+)/(:num)' => 'view/$1/$2', //Route for URI 'forums/boards/Board_Name/123
          'delete/:(num)' => 'delete/$1' //Route for URI 'forums/boards/delete/123'
     'threads' => array(
          '([a-z]+)/(:num')' => 'view/$1/$2, //Route for URI 'forums/threads/Thread_Name/123
          'edit/(:num)' => 'edit/$1', //Route for URI 'forums/threads/edit/123
          'delete/(:num' => 'delete/$1', //Route for URI 'forums/threads/delete/123

In a single line, a route for the uri 'forums/boards/Board_Name/123' would look something like this:
$route['forums']['boards']['([a-z]+)/(:num)'] = 'forums/boards/view/$1/$2';

The array for controllers that aren't in a subdirectory would have to be defined before the ones that are in a subdirectory. Otherwise, PHP would replace the subdirectory array with the main directory array.

I just think something like this might make it alot easier to manage URI routes. Any thoughts?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.