您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

yii2模块的独立配置不生效

2024/11/14 16:39:04发布33次查看
我项目中有一v1模块,在v1.php中的init代码中加载了配置
parent::init(); yii::configure($this, [ 'components'=>[ 'errorhandler' => [ 'class'=>'app\modules\v1\common\errorhandler' ] ] ]);

然后我在控制器中加了一行throw new httpexception(403);
最后控制器中怎么没走到我自定义的errorhandle里面呢?
可是我在项目中的config/web.php的components中加入
'errorhandler' => [ 'class'=>'app\modules\v1\common\errorhandler' ]

就能够正常走自定义的errorhandler,这是为什么呢?
回复内容: 我项目中有一v1模块,在v1.php中的init代码中加载了配置
parent::init(); yii::configure($this, [ 'components'=>[ 'errorhandler' => [ 'class'=>'app\modules\v1\common\errorhandler' ] ] ]);

然后我在控制器中加了一行throw new httpexception(403);
最后控制器中怎么没走到我自定义的errorhandle里面呢?
可是我在项目中的config/web.php的components中加入
'errorhandler' => [ 'class'=>'app\modules\v1\common\errorhandler' ]

就能够正常走自定义的errorhandler,这是为什么呢?
v1模块的init改成
parent::init();yii::$app->errorhandler->erroraction = 'app\modules\v1\common\errorhandler';
试试看
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product