You could use the onBeginRequest
event of the application. This usually requires you to add some code to your index.php
. Here's a quick example:
$app = Yii::createWebApplication($config);
$app->onBeginRequest = function($event) {
// ... whatever you want to do
}
$app->run();
Of course instead of a closure function you can also attach any other valid callback.