Events
Source-reviewed against the pinned revision below. This is a component integration guide, not a claim of a complete tested application matrix.
Package and installation
Section titled “Package and installation”triangle/events · AGPL-3.0-or-later
composer require triangle/eventscomposer check-platform-reqscomposer show triangle/eventsThe command resolves the available release, not necessarily the source revision reviewed here. Keep and validate your application lock. Direct requirements do not describe all transitive PHP/extension constraints.
| Requirement | Constraint |
|---|---|
php | ^8.1 |
triangle/engine | ^8.1 |
Dispatch model
Section titled “Dispatch model”The API is support\Events: named string events, callable listeners and process-local static registries. Callbacks receive (data, eventName). This is synchronous local dispatch, not a durable event bus, queue or cross-worker broadcast. No Event or ListenerInterface base class is required.
Register, emit and remove
Section titled “Register, emit and remove”use support\Events;
$id = Events::on('docs.ready', static function (array $data, string $name): string { return $name . ':' . $data['id'];});$responses = Events::emit('docs.ready', ['id' => 'example']);Events::off('docs.ready', $id);Return values
Section titled “Return values”on() returns an integer subscription ID. emit() returns listener responses; halt=true returns the first non-null response, otherwise null. A false response stops dispatch. getListeners(), list() and hasListener() inspect registrations. A name ending in * registers a prefix listener.
Source defects and configuration boundary
Section titled “Source defects and configuration boundary”The reviewed Bootstrap::load checks is_callable($callbacks) instead of the converted individual callback: a normal event-to-listeners config can throw. Do not claim config-driven listeners work until fixed/tested. off() only removes exact-name registrations, not prefix registrations. The exception path accesses an uninitialized typed logger; do not assume listener exceptions are safely logged. The old listeners wrapper was not the bootstrap format. Direct on/emit/off of successful exact-name listeners is the narrow supported example here.
Source and verification
Section titled “Source and verification”Events · a41f0185f142. Framework startup limits.