spiral-packages/league-event
Spiral Framework bridge for The League Event dispatcher. Provides an EventBootloader to wire PSR-style event dispatching, define event classes, and register listeners via attributes or config. Requires PHP 8.1+ and Spiral 3.0+.
Begin by installing the package via Composer (composer require spiral-packages/league-event) and enabling the provider in app/src/Kernel.php (typically via Spiral\Packages\Event\EventBootloader). Once registered, the dispatcher is available in the DI container as League\Event\EventDispatcherInterface. Your first use case is dispatching a simple domain event (e.g., UserRegistered) and wiring up a listener to send a welcome email — no manual handler instantiation needed.
#[Listener] on handler methods or configure listeners in config/event.php (e.g., mapping event classes to handler services).class OrderShipped { public $orderId; }); type-hint the event in listener signatures for strict binding.EventDispatcherInterface into services/controllers and call $dispatcher->dispatch(new UserRegistered($user));.EventDispatcherInterface or assert dispatched events using event collectors in unit tests.Spiral\Core\Interceptor\InterceptorInterface support) — class names alone won’t be resolved automatically.FilterEvent or ListenerFilter, remember to register filters before listeners in config to avoid early termination.event section in /debug for listener chain execution.How can I help you explore Laravel packages today?