How to bind more than one handlers to event in config file?

I want to bind more than one handlers to a event, I know I can call Component::on() many times, but I want to do it in a configuration way (in main.php). How ? Thanks.

Anonymous function?

You mean attach handlers in anonymous function? like Yii::$app->on(‘beforeRequest’,function()) ? It’s ok. but not so “configurable”.

So Yii does not support to add multiple handlers to one event in main.php?

Or we can use behavior? we can attach multiple behaviors in main.php

You can add different number of spaces between “on” and event name but that’s rather hacky.

It will surely solve the problem I think. Good idea but a little strange. I would rather to use behaviors. The number of behaviors is not limited.

Thankx.