php 如何在 Yii 中设置默认控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11373057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:22:02  来源:igfitidea点击:

How to set default controller in Yii

phpyii

提问by JohnnyQ

Is there a way to specify a default controller in Yii? Instead of using the SiteController? Thank you in advance.

有没有办法在 Yii 中指定默认控制器?而不是使用 SiteController?先感谢您。

回答by Moyed Ansari

To set your default controller as your homepage's controller on Yii PHP-Framework. You must modify the core defaults controller (site/index) on your /protected/config/main.php

在 Yii PHP-Framework 上将您的默认控制器设置为主页的控制器。您必须修改 /protected/config/main.php 上的核心默认控制器(站点/索引)

return array(
    'name' => 'Web Application',
    'defaultController' => 'home ', 

);

回答by bingjie2680

try to add the configuration in the config main.php

尝试在config main.php中添加配置

'defaultController' => 'newcontrollername',

after 'name' setting.

在“名称”设置之后。

回答by esxzawq

also there is another way to do that

还有另一种方法可以做到这一点

change the values of public $defaultController property in

更改公共 $defaultController 属性的值

framework/web/CWebApplication.php

框架/网络/CWebApplication.php