php - yii2模块的独立配置不生效
PHPz
PHPz 2017-04-10 17:53:53
0
1
535

我项目中有一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,这是为什么呢?

PHPz
PHPz

学习是最好的投资!

reply all(1)
左手右手慢动作

v1模块的init改成

parent::init();
Yii::$app->errorHandler->errorAction = 'app\modules\v1\common\ErrorHandler';

试试看

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!