Change location of controller inside of Yii

2019-09-06 14:57发布

I want to change the location of my siteController from protected/controllers to protected/backOffice/controllers.

I have tried to do the following inside of the main config file but it gives me a CExxception error and its doesnt give the much of information

Unable to resolve the request "site/error". (C:\Users\steve\Sync\Frameworks\yii\framework\web\CWebApplication.php:286)

and i have the following inside of the import

'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.backoffice.*',
    ),

How i can do this i have found this little helper but still cant understand where i have to put it. Link

标签: yii
1条回答
Explosion°爆炸
2楼-- · 2019-09-06 15:42

According to your config file, it should look like:

'controllerPath'=>'protected/backoffice',  <== Add this line
'import'=>array(
    'application.models.*',
    'application.components.*',
    //'application.backoffice.*',  <=== You don't need this
),

You can achieve the single controller in backoffice by: Removing the controllerPath from main.php and add the following:

'controllerMap'=>array(
    'booklet'=>array(
        'class'=>'application.backoffice.Booklet', //<== Your controller name
    ),        
),
查看更多
登录 后发表回答