在 Yii 中更改控制器的位置 [英] Change location of controller inside of Yii

查看:27
本文介绍了在 Yii 中更改控制器的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的 siteController 的位置从 protected/controllers 更改为 protected/backOffice/controllers.

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

我尝试在主配置文件中执行以下操作,但它给了我一个 CExxception 错误并且它没有提供很多信息

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)

我在导入中有以下内容

'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

推荐答案

根据你的配置文件,它应该是这样的:

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
),

您可以通过以下方式在后台实现单控制器:从 main.php 中删除 controllerPath 并添加以下内容:

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
    ),        
),

这篇关于在 Yii 中更改控制器的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆