这篇关于yii框架设计模式的文章,主要介绍yii框架如何配置默认controller与action,觉得挺不错的,感兴趣的php开发者可以参考下,希望对大家在学习php的成长路上有所帮助!
本文介绍了yii框架中配置默认controller和action的方法,分享一个设置默认controller和action的例子,有学习yii的朋友可以参考下,个人感觉还不错的。
在yii框架中,设置默认 controller 在/protected/config/main.php添加配置,具体代码如下:
<?php
return array(
'name'=>'Auto',
'defaultController'=>'auto',
......
上述配置了默认的 controller 为 AutoController.php
在yii框架中,设置默认 action 在刚才定义的 AutoController.php 中设置,具体代码如下:
<?php
class AutoController extends CController{
public $defaultAction='test';
public function actionTest(){
...
}
...
此时访问 xxxx/index.php,会默认转到 xxxx/index.php?r=auto/test,表示设置成功。
总结
以上就是关于yii框架设计模式全部内容,希望这篇yii框架如何配置默认controller与action文章能够帮你解决如相关的PHP问题,更多请关注PHP栏目的其它相关文章!