PHPackages                             fig/event-dispatcher-util - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fig/event-dispatcher-util

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fig/event-dispatcher-util
=========================

Useful utility classes and traits for implementing the PSR events standard

1.4.0(3d ago)27473.2k—0.8%8[1 PRs](https://github.com/php-fig/event-dispatcher-util/pulls)18MITPHPPHP &gt;=8.1CI passing

Since Aug 20Pushed 2y ago7 watchersCompare

[ Source](https://github.com/php-fig/event-dispatcher-util)[ Packagist](https://packagist.org/packages/fig/event-dispatcher-util)[ Docs](https://github.com/php-fig/event-dispatcher-util)[ Fund](https://opencollective.com/php-fig)[ RSS](/packages/fig-event-dispatcher-util/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (15)Used By (18)

PSR-14 Event Dispatcher Utility Library
=======================================

[](#psr-14-event-dispatcher-utility-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0c7bd995305b8b84c723c8861a2bb4baa918a6e612f0b9514b658cdf8e28cf92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6669672f6576656e742d646973706174636865722d7574696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fig/event-dispatcher-util)[![Software License](https://camo.githubusercontent.com/458425f8985b0b0c8a736cffe75e05a098e3d77906acddbcad2bfc54492a4e02/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/4aa15e65831007e8843e6cfff239b73edd3bb7664f4d84ef3a2ea60804d03eb4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6669672f6576656e742d646973706174636865722d7574696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fig/event-dispatcher-util)

This package contains a series of traits and base classes to cover the common, boilerplate portions of implementing a PSR-14-compliant event dispatcher library.

Install
-------

[](#install)

Via Composer

```
$ composer require fig/event-dispatcher-util
```

Usage
-----

[](#usage)

### Aggregate provider

[](#aggregate-provider)

The `AggregateProvider` class is a `ListenerProvider` implementation that collects and concatenates other listener providers. It is a simple wrapper that `yield`s from a series of configured providers, in order.

```
use Fig\EventDispatcher\AggregateProvider;

$provider1 = new YourProvider();
$provider2 = new SomeOtherProvider();

$provider = (new AggregateProvider())
    ->addProvider($provider1)
    ->addProvider($provider2)
;

$dispatcher = new SomeDispatcher($provider);
```

The aggregate provider will now return all the listeners from `YourProvider`, followed by all the listeners from `SomeOtherProvider`.

### Delegating provider

[](#delegating-provider)

The `DelegatingProvider` is another multi-provider front-end. In this case, it can be configured such that certain event types will use one sub-provider, and others will use a different one. A given type can be configured with multiple sub-providers, and events will be matched using `instanceof` so that sub-classes of an event are also affected.

```
use Fig\EventDispatcher\DelegatingProvider;

$requestProvider = new KernelListenerProvider();
$ormProvider = new OrmListenerProvider();

$defaultProvider = new SomeDefaultProvider();

// Assume HttpEvent and OrmEvent are interfaces for event classes.

$provider = (new DelegatingProvider($defaultProvider))
    ->addProvider($requestProvider, [HttpEvent::class])
    ->addProvider($ormProvider, [OrmEvent::class])
;

$dispatcher = new SomeDispatcher($provider);
```

Now, events sent to the dispatcher that implement `HttpEvent` will be passed along to `KernelListenerProvider` only, while those that implement `OrmEvent` will be passed along to `OrmListenerProvider` only. Any other events will be passed on to the default provider only.

`AggregateProvider` and `DelegateProvider` are fully compatible with each other, so either can use an instance of the other as one of its sub-providers.

### Parameter provider helpers

[](#parameter-provider-helpers)

The `ParameterDeriverTrait` is a set of tools to help listener provider implementations with deriving the type of a callable's parameter, to know what type of event it is. PHP supports a wide variety of callable types, which are not always easy to disambiguate. The tools in this class help ease that process.

If you are not writing your own Provider registration mechanism, this trait will not be useful.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email one of the current PHP-FIG Secretaries instead of using the issue tracker.

License
-------

[](#license)

This package is released under the MIT license. Please see [License File](LICENSE.md) for more information.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance55

Moderate activity, may be stable

Popularity48

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 63% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~221 days

Recently: every ~661 days

Total

14

Last Release

3d ago

Major Versions

0.7.2 → 1.0.02019-03-25

PHP version history (4 changes)0.4.0PHP ~7.1

0.7.0PHP ~7.2

1.2.0PHP &gt;=7.2

1.4.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/121632?v=4)[Fig](/maintainers/fig)[@fig](https://github.com/fig)

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

![](https://www.gravatar.com/avatar/12e28c223b88445f07d697c8805bd856066c947f70b535f6a7e00d2cb311c3c2?d=identicon)[Crell](/maintainers/Crell)

---

Top Contributors

[![Crell](https://avatars.githubusercontent.com/u/254863?v=4)](https://github.com/Crell "Crell (34 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (6 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (4 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (3 commits)")[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (2 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (1 commits)")[![jbboehr](https://avatars.githubusercontent.com/u/225601?v=4)](https://github.com/jbboehr "jbboehr (1 commits)")[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (1 commits)")[![sunkan](https://avatars.githubusercontent.com/u/568492?v=4)](https://github.com/sunkan "sunkan (1 commits)")[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (1 commits)")

---

Tags

eventspsr-14

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fig-event-dispatcher-util/health.svg)

```
[![Health](https://phpackages.com/badges/fig-event-dispatcher-util/health.svg)](https://phpackages.com/packages/fig-event-dispatcher-util)
```

###  Alternatives

[psr/event-dispatcher

Standard interfaces for event handling.

2.3k667.1M1.4k](/packages/psr-event-dispatcher)[phpro/soap-client

A general purpose SoapClient library

8896.1M54](/packages/phpro-soap-client)[crell/tukio

A robust, stand-alone PSR-14 event dispatcher implementation.

114214.2k17](/packages/crell-tukio)[shopware/app-php-sdk

Shopware App SDK for PHP

15109.8k3](/packages/shopware-app-php-sdk)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

1595.5k](/packages/eliashaeussler-typo3-form-consent)[php-opcua/opcua-client

Pure PHP OPC UA client — binary protocol over TCP, 6 security policies, browse/read/write/subscribe/history, zero external dependencies

131.4k23](/packages/php-opcua-opcua-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
