I just started using Laravel. When I use codeigniter or zend framework, I can organize my controller into a separate directory. For example, I can create 'user/permission.php' and 'user/group.php'.
How do I do that with Laravel?
Convert /
into _
. So your controllers/user/permission.php
controller would be
class User_Permission_Controller
You also have to route to the controller changing _
to .
So route similar to
Route::get('/', 'user.permission@index');
You can see more details on it here. http://codehappy.daylerees.com/using-controllers
(This is basically the same answer as Robbo gave with some extra examples).
I use the following (tested) structure. I have a file controllers/admin.php which looks like:
class Admin_Controller extends Base_Controller {
...
}
And I have files like controller/admin/groups.php which look like:
class Admin_Groups_Controller extends Admin_Controller {
...
}
And in the routes.php file I have
// Route to all controllers
Route::controller(Controller::detect());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With