[置顶] YII2 模块内自定义错误页

来源:互联网 发布:centos wireshark 2.0 编辑:程序博客网 时间:2024/06/05 06:10

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

<?phpnamespace 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

0 0
原创粉丝点击