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(


            'class'=>'application.controllers.orders.OrdersController'


        ),


        'index'=> array(


            'class'=>'application.controllers.index.IndexController'


        ),

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?

Thanks.

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

For example, index.index or orders.orders

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

Thanks,

Let's say you have a controller located as:

protected

    controllers

        admin

              user

                    ProfileController.php

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.