ITeye博客

YII2 模块内自定义错误页

vb2005xu · 2015-11-07 12:17 · vb2005xu自己动手系列 · 开源软件 · Yii · Markdown

当前YII框架中把错误异常配置都放置在 web.php 中,对于新增的模块 module 非常不方便,而且文档中基本没有任何教程,此处给大家分享一个方法:

<?php

namespace app\modules\cangshu;

class Module extends \yii\base\Module
{
    public $controllerNamespace = 'app\modules\cangshu\controllers';

    public function init()
    {
        parent::init();

        // \Yii::configure($this->module, require(__DIR__ . '/config.php'));
        
        // 自定义错误页
        \Yii::$app->errorHandler->errorAction = 'cangshu/error/view';
    }
}

希望对大家有用,更多内容请看我博客: http://vb2005xu.iteye.com

评论(1)

  1. #1 楼 · vb2005xu · 2016-01-10 20:25

    http://geekplux.com/wiki/

评论功能维护中,当前仅展示历史评论。