# Technical Documentation: symfony/event-dispatcher

> ℹ️ **Provenance:** In-Tree Documentation (3 Chapters) · [CodeWiki Reference](https://codewiki.google/github.com/symfony/event-dispatcher) · Recency: Active (< 180 days)

## File: README.md

EventDispatcher Component
=========================

The EventDispatcher component provides tools that allow your application
components to communicate with each other by dispatching events and listening to
them.

Sponsor
-------

This package is looking for a [backer][1].

Help Symfony by [sponsoring][3] its development!

Resources
---------

 * [Documentation](https://symfony.com/doc/current/components/event_dispatcher.html)
 * [Contributing](https://symfony.com/doc/current/contributing/index.html)
 * [Report issues](https://github.com/symfony/symfony/issues) and
   [send Pull Requests](https://github.com/symfony/symfony/pulls)
   in the [main Symfony repository](https://github.com/symfony/symfony)

[1]: https://symfony.com/backers
[3]: https://symfony.com/sponsor

---

## File: CHANGELOG.md

CHANGELOG
=========

8.2
---

 * Add `CompiledEventDispatcher` and `CompileListenersPass` to dispatch to the listeners a container describes at compile time
 * Add `ScopedEventDispatcher`, to give listeners the lifetime of a scope without mutating the dispatcher they run next to
 * Add `Symfony\Contracts\EventDispatcher\ListenerIntrospectionInterface`, extended by `EventDispatcherInterface`, to read the listeners of a dispatcher without registering any
 * Deprecate calling `addListener()`, `addSubscriber()`, `removeListener()` and `removeSubscriber()` on a `CompiledEventDispatcher`, declare the listener in the container or add it to a `ScopedEventDispatcher` instead
 * Allow `getSubscribedEvents()` to name its keys: `['method' => 'onEvent', 'priority' => 10]`
 * Add `before` and `after` to `#[AsEventListener]` and to the named keys of `getSubscribedEvents()` to order listeners, and make `AsEventListener::$priority` nullable
 * Add `CompiledEventDispatcher::shutdown()` to release the listeners

8.1
---

 * Add hot-path and no-preload event support to `AddEventAliasesPass`
 * Deprecate `RegisterListenersPass::setHotPathEvents()` and `setNoPreloadEvents()`, use `AddEventAliasesPass` instead

6.0
---

 * Remove `LegacyEventDispatcherProxy`

5.4
---

 * Allow `#[AsEventListener]` attribute on methods

5.3
---

 * Add `#[AsEventListener]` attribute for declaring listeners on PHP 8

5.1.0
-----

 * The `LegacyEventDispatcherProxy` class has been deprecated.
 * Added an optional `dispatcher` attribute to the listener and subscriber tags in `RegisterListenerPass`.

5.0.0
-----

 * The signature of the `EventDispatcherInterface::dispatch()` method has been changed to `dispatch($event, string $eventName = null): object`.
 * The `Event` class has been removed in favor of `Symfony\Contracts\EventDispatcher\Event`.
 * The `TraceableEventDispatcherInterface` has been removed.
 * The `WrappedListener` class is now final.

4.4.0
-----

 * `AddEventAliasesPass` has been added, allowing applications and bundles to extend the event alias mapping used by `RegisterListenersPass`.
 * Made the `event` attribute of the `kernel.event_listener` tag optional for FQCN events.

4.3.0
-----

 * The signature of the `EventDispatcherInterface::dispatch()` method should be updated to `dispatch($event, string $eventName = null)`, not doing so is deprecated
 * deprecated the `Event` class, use `Symfony\Contracts\EventDispatcher\Event` instead

4.1.0
-----

 * added support for invokable event listeners tagged with `kernel.event_listener` by default
 * The `TraceableEventDispatcher::getOrphanedEvents()` method has been added.
 * The `TraceableEventDispatcherInterface` has been deprecated.

4.0.0
-----

 * removed the `ContainerAwareEventDispatcher` class
 * added the `reset()` method to the `TraceableEventDispatcherInterface`

3.4.0
-----

 * Implementing `TraceableEventDispatcherInterface` without the `reset()` method has been deprecated.

3.3.0
-----

 * The ContainerAwareEventDispatcher class has been deprecated. Use EventDispatcher with closure factories instead.

3.0.0
-----

 * The method `getListenerPriority($eventName, $listener)` has been added to the
   `EventDispatcherInterface`.
 * The methods `Event::setDispatcher()`, `Event::getDispatcher()`, `Event::setName()`
   and `Event::getName()` have been removed.
   The event dispatcher and the event name are passed to the listener call.

2.5.0
-----

 * added Debug\TraceableEventDispatcher (originally in HttpKernel)
 * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface
 * added RegisterListenersPass (originally in HttpKernel)

2.1.0
-----

 * added TraceableEventDispatcherInterface
 * added ContainerAwareEventDispatcher
 * added a reference to the EventDispatcher on the Event
 * added a reference to the Event name on the event
 * added fluid interface to the dispatch() method which now returns the Event
   object
 * added GenericEvent event class
 * added the possibility for subscribers to subscribe several times for the
   same event
 * added ImmutableEventDispatcher

---

## File: composer.json

{
    "name": "symfony/event-dispatcher",
    "type": "library",
    "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
    "keywords": [],
    "homepage": "https://symfony.com",
    "license": "MIT",
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "require": {
        "php": ">=8.4.1",
        "symfony/deprecation-contracts": "^2.5|^3",
        "symfony/event-dispatcher-contracts": "^3.8"
    },
    "require-dev": {
        "psr/log": "^1|^2|^3",
        "symfony/config": "^7.4|^8.0",
        "symfony/dependency-injection": "^8.2",
        "symfony/error-handler": "^7.4|^8.0",
        "symfony/expression-language": "^7.4|^8.0",
        "symfony/framework-bundle": "^7.4|^8.0",
        "symfony/http-foundation": "^7.4|^8.0",
        "symfony/service-contracts": "^2.5|^3",
        "symfony/stopwatch": "^7.4|^8.0",
        "symfony/var-dumper": "^7.4|^8.0"
    },
    "conflict": {
        "symfony/dependency-injection": "<8.2",
        "symfony/security-http": "<7.4",
        "symfony/service-contracts": "<2.5"
    },
    "provide": {
        "psr/event-dispatcher-implementation": "1.0",
        "symfony/event-dispatcher-implementation": "2.0|3.0"
    },
    "autoload": {
        "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" },
        "exclude-from-classmap": [
            "/Tests/"
        ]
    },
    "minimum-stability": "dev"
}

--- METRICS ---
- Files Extracted: 3
- Estimated Token Budget: ~1622 tokens
- Recency Window: Active (< 180 days)
- Canonical Reference: https://codewiki.google/github.com/symfony/event-dispatcher
