Accessing a controller

I have the following controller structure:

  • protected
    • controllers
      • index
        • IndexController.php
      • orders
        • OrdersController.php

Unless i go in the config/main.php file to add those :

'orders'=> array(



        'index'=> array(



to the 'controllerMap' array i cannot access the controllers by accessing index.php?r=index or index.php?r=orders

Is there anyway to override the need to add the controller to the 'controllerMap' array every time a new controller is added?


Because your controls are in subdirectories of 'controllers', you can refer to them using:

For example, index.index or orders.orders

Sorry didn't quite get it, Could you elaborate?


Let's say you have a controller located as:






The ID for this controller would be 'admin.user.profile', and the route for an action 'edit' of this controller would be 'admin.user.profile/edit'. You don't need declare the controller in the controllerMap if you refer to your controller using this ID format.

Ahh got it, Very clever. Thanks.