using several modules with default controllers

I need to implement HMVC in my application by calling forward() to several different modules.

Each module has a default controller named DefaultController, as we know. I can’t load different classes with the same name. I can use namespaces in modules, but I can’t call a controller that is in a namespace.

The solution is to write the $controllerMap in modules.

I have a module called "sample1".

In the file app/modules/Sample1Module.php:




class Sample1Module extends CWebModule

{

    public $controllerMap = array(

        'default'=>'sample1\controllers\DefaultController'

    );



In the file app/modules/sample1/controllers/DefaultController.php:




<?php


namespace sample1\controllers;


class DefaultController extends \Controller

{

...



This allows enclosing the module controller in its own namespace.