Home > php教程 > php手册 > yii框架配置默认controller和action示例

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:36:52
Original
991 people have browsed it

设置默认controller

在/protected/config/main.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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template