symfony/event-dispatcher
Symfony’s EventDispatcher component lets application parts communicate by dispatching events to registered listeners and subscribers. Build decoupled, extensible workflows with a simple API for adding, removing, and prioritizing handlers.
Event system but adds prioritization, propagation control, and Symfony’s robust abstractions.LogEventListener can handle GDPR compliance across all services.#[AsEventListener] attribute (v8.0+) reduces boilerplate for PHP 8.1+ users.TraceableEventDispatcher makes it viable for long-running Laravel processes (queues, CLI workers, cron jobs), addressing a critical gap in Laravel’s native event system.illuminate/events), so no breaking changes are expected. Laravel’s Event facade and EventServiceProvider are drop-in replacements for Symfony’s EventDispatcher.TraceableEventDispatcher Usage: If your app directly uses this class (not recommended in Laravel), validate the v8.0.8 memory leak fix in long-running processes.#[AsEventListener]) require PHP 8.1+, which may need polyfills or gradual adoption in older Laravel versions.symfony/ux-live-component) and scaling considerations (e.g., Redis pub/sub).TraceableEventDispatcher directly? If so, test the v8.0.8 memory fix in long-running processes (e.g., Laravel Queues).illuminate/events component. No changes are needed for basic event dispatching (Event::dispatch(), Event::listen()).#[AsEventListener]) and union types.assertDispatched()).| Current State | Migration Path | Effort |
|---|---|---|
| Using Laravel’s native events | No action needed. The package is already used under the hood. | 0 (zero effort) |
| Custom event system | Replace with EventDispatcher + Laravel’s Event facade. |
Low |
| Symfony components (Doctrine, etc.) | Use symfony/event-dispatcher directly for consistency. |
Medium |
| Long-running processes (Queues) | Upgrade to v8.0.8+ to leverage the memory leak fix. | Low |
| PHP < 8.1 | Use v7.4.x and avoid attributes (#[AsEventListener]). |
Low |
EventServiceProvider or app/Listeners.TraceableEventDispatcher usage.symfony/event-dispatcher:^8.0 (PHP 8.1+).symfony/event-dispatcher:^7.4 (PHP 7.4+).TraceableEventDispatcher, validate the v8.0.8 memory fix in:
php artisan queue:work).php artisan your:command).#[AsEventListener]) in PHP 8.1+.OrderCreated, UserRegistered) in a shared Events namespace.stopPropagation()).composer update.SplObjectStorage deprecations in v7.3+).Event::assertDispatched(): Assertions forHow can I help you explore Laravel packages today?