Infinite Loop Yii Run Controller

There is structure of small yii application:


 |_ protected

     |_ config

     |   |_main.php    

     |_ controllers

     |   |_ DefaultController.php

     |_ modules

     |   |_  moduleA

     |   |   |_ controllers

     |   |   |   |_ DefaultController.php

     |   |   |_ ModuleAModule.php

     |   |_  moduleB

     |       |_ controllers

     |       |   |_ DefaultController.php

     |       |_ ModuleBModule.php

     |_ views

|_ www

    |_ index.php


class DefaultController extends CController


    public function actionIndex()


        echo "moduleA/index";


    public function actionTest()


        echo "moduleA/test";




class DefaultController extends CController


    public function actionIndex()




    public function actionTest()


        echo "moduleB/test";



if I run URL: /moduleb/default/index i get this:

Fatal error: Maximum function nesting level of ‘100’ reached, aborting! in /Users/ifrinx/www/YiiNode/framework/YiiBase.php on line 8

How i can solve this problem?



otherwise use CController::redirect

if it was easy as in manual i not write here <_<

‘createContoller’ and redirection is not that i need, because i need to run other controller by route in current controller, my goal is stay at the current URL and run other module inspite of it’s parameters list

would forward() work for your case?

Use absolute route format with leading "/":

Instead of ‘modulea/default/index’ use ‘/modulea/default/index’.

‘forward’ method or writing a slash in the beging of the route couldn’t solve this problem

There is an attach in message with current small project without framework, you could get this error

i think it could be framework error :huh:

Use different Controller name in the modules - now both are DefaultController.

Your problem appears because you have 2(!) controllers with the same name “DefaultController” in your application.

When you request route “moduleb/default/index” the file “moduleb/controllers/DefaultController” is loaded by Yii autoload for the class “DefaultController”. Then you request route “modulea/default/index”, which requires controller with the same name “DefaultController”, which is already filled up with “moduleb/controllers/DefaultController”, so you get an infinite recursion.

That is one of the reasons namespaces have been invented.

To solve your problem you should name the default controllers for your modules differently.