Yii event is the first framework-specific package from Yii 3 family. Its goal is to make configuring events convenient. For the applications it provides three main config files:
events.php - Common event handlers for web and console.
events-web.php - Web event handlers.
events-console.php - Console event handlers.
The config syntax is the following:
return [
EventName::class => [
static fn (EventName $event) => someStuff($event),
static fn (EventName $event, DependencyClass $dependency) => someStuff($event),
[SomeClass::class, 'staticMethodName'],
[SomeClass::class, 'methodName'],
new InvokableClass(),
InvokableClass::class,
'di-alias'
],
];
For convenience, there's a configuration checker that is used in current application templates to check if all handlers declared are correct.