O'Reilly logo

Web Application Development with Yii 2 and PHP by Jeffrey Winesett, Mark Safronov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Built-in events

Here, we'll save you from a full-text search through the quite extensive code base of Yii 2 and will list everything starting with EVENT_ defined in the framework. Note that you should provide a string as a $name argument in the on() method. All built-in events define these strings as class constants, and you should always use these class constants when attaching event handlers instead of its actual values.

Events of \yii\base\Application

Both the web and the console applications shipped with Yii 2 will trigger the following events. Nothing will be passed as $event to trigger(), so expect a default event object. Then, we can proceed to your handlers. Have a look at the following table:

Event name

When is it triggered

EVENT_BEFORE_REQUEST ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required