triangle / events
Triangle Events Component
Fund package maintenance!
Requires
- php: ^8.1
- psr/log: ^2.0 || ^3.0
- triangle/engine: ^9.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-21 01:58:31 UTC
README
Triangle Events
Triangle Events registers application event listeners during Engine startup and provides an in-process dispatcher with exact-name and prefix listeners.
Requirements
- PHP 8.1 or later
- Triangle Engine 9.x
Install the package with Composer:
composer require triangle/events:^2.0
Register and dispatch events
use support\Events; Events::on('invoice.created', static function (array $invoice, string $event): void { // Handle the created invoice. }); Events::emit('invoice.created', ['id' => 42]);
Use a trailing * to register a prefix listener, for example invoice.*. Listeners receive the event payload followed by the event name. Dispatch is process-local; it does not provide durable queueing or cross-worker delivery.
Listeners can also be declared in config/event.php:
return [ 'invoice.created' => [ [App\Listeners\InvoiceCreated::class, 'handle'], ], ];
The Engine bootstrap loads application and plugin event configuration at startup. Engine 8 is not supported: this component uses the plugin configuration hooks introduced in Engine 9.
Русская версия: README.ru.md.