Reputation: 35384
In Yii, when access to <app-host>/index.php?r=<mycontroller>/<myaction>
, the framework will start to run code in protected/controller/<MyController>Controller.php
I want to that code to be located in another folder, says protected/anotherFolder
, while other controllers remain as-is. How to do that?
Regards
Upvotes: 1
Views: 5235
Reputation: 1687
You can add to config file
'controllerPath' => 'your_new_controller_path',
The same with view path
'viewPath' => 'path_to_template_folder',
Upvotes: 3
Reputation: 6647
If I got you, you want to split the web logic into different "folders", or (in a more yii-ly way) modules. For instance, to have all the administrating stuff into another place and get to this using r=admin/users, for instance
If you have your gii manager activated, go to /index.php?r=gii, and create a module. That's it. You can then create controllers inside protected/modules/<module-name>
/controllers/ and call them using that path. Of course, views are also stored inside that
Upvotes: 3
Reputation: 35384
Thanks to mdomba
on yii forum at this post, I found the answer using CWebApplication::controllerMap
- in the loading state of the application we call
Yii::app()->controllerMap['yourControllerName']='path.alias.to.your.controller.file.without.dotPHP';
You can use controllerMap - http://www.yiiframew...ollerMap-detail
Upvotes: 5
Reputation: 621
Open up <app-host>/index.php
, edit to
//...
require_once($yii);
$app = Yii::createWebApplication($config);
$app->setControllerPath('protected/anotherFolder');
$app->run();
Upvotes: 6