yii框架配置默认controller和action示例

内容摘要
设置默认controller
在/protected/config/main.php添加配置
复制代码 代码如下:<?phpreturn array( 'name'=>'Auto','defaultController'=>'auto',
上述配置了默认的control
文章正文

设置默认controller

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

复制代码 代码如下:

<?php
return array(
 'name'=>'Auto',
'defaultController'=>'auto',

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

设置默认action

在AutoController.php中设置

复制代码 代码如下:

class AutoController extends CController
{
    public $defaultAction = 'test';

    public function actionTest()
    {
        ...
    }
    ...

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


代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!