首页 >php教程 >php手册 >Yii 配置默认controller和action

Yii 配置默认controller和action

WBOY
WBOY原创
2016-06-13 09:39:491401浏览

设置默认controller

  在/protected/config/main.php添加配置

<span 1</span> <?<span php
</span><span 2</span> <span return</span> <span array</span><span (
</span><span 3</span>     'name'=>'Auto',
<span 4</span>     'defaultController'=>'auto',
<span 5</span>     ...

  上述配置了默认的controller为AutoController.php

 

设置默认action

  在AutoController.php中设置

<span class</span> AutoController <span extends</span><span  CController
{
    </span><span public</span> <span $defaultAction</span> = 'test'<span ;

    </span><span public</span> <span function</span><span  actionTest()
    {
        </span>...<span 
    }
    </span>...

  此时访问xxxx/index.php会默认转到xxxx/index.php?r=auto/test

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
上一篇:PM2.5数据采集下一篇:phpcms学习总结