Events are a powerful tool to escape and interact between various pieces of functionality. In general, there are only a few methods:
- \Neoan3\Core\Event::listen($eventname, $closure )
- \Neoan3\Core\Event::listenAll($closure )
- \Neoan3\Core\Event::dispatch($eventname, $closure )
- \Neoan3\Core\Event::hook($eventname, $closure)
// example in default.php: \Neoan3\Core\Event::listen('Core::beforeInit', fn($event) => var_dump($event))
You can dispatch custom events as needed using Event::dispatch. Here we want to give you a quick look at existing core-events:
Earliest event fired. This event happens AFTER resources are loaded and BEFORE any methods, instances or functions are called.
This event happens AFTER a route has been searched for and BEFORE a 404 redirect and header gets served.
Fired when PHP8 attribute was encountered.
This event happens AFTER the API handler has been initialized and BEFORE processing of the request begins.
This event happens AFTER the API has completed the request and BEFORE the response is sent to the client.
This event happens AFTER the API has completed the request and AFTER the response is sent to the client.
(Getting ideas?: neoan3 does not ship with parallelism out of the box. We play nicely with Spatie's Asynchronous and parallel PHP and are fans of Swoole)
This event happens on multiple occasions AFTER an issue was encountered and BEFORE a response is sent to the client.