1
votes

How can I add an event handler in a yii2 application configuration file. In the guide it is specified, but not clearly explained. I don't want to create a component then bootstrap, and attach a handler in the component.

I just simply want to alter configuration params with the help of the Yii::$app->basePath parameter.

Now I can't use Yii::$app on params.php, because the application is still not bootstrapped.

1
Fixed some grammar to make it more understandable - Rico

1 Answers

1
votes

Sorry. I just misunderstood the guide. It is very simple as yii2 itself. Just need to attach the 'on beforeRequest' => function( $event) {...} , in the configuration file at first level. IN doc there is [ 'on beforeRequest'...] . This syntax just make me confused.