当前位置: 首页 > 新闻动态 > 软件编程

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

作者:用户投稿 浏览: 发布日期:2026-01-16
[导读]:这篇文章主要介绍了yii框架配置默认controller和action示例,需要的朋友可以参考下

设置默认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

免责声明:转载请注明出处:http://jing-feng.com.cn/news/311865.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!