PHPackages                             pleets/php-event-dispatcher - 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. pleets/php-event-dispatcher

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

pleets/php-event-dispatcher
===========================

PSR-14 Event Dispatcher

v1.0.0(5y ago)094MITPHPPHP 7.4.\*

Since Jul 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pleets/php-event-dispatcher)[ Packagist](https://packagist.org/packages/pleets/php-event-dispatcher)[ Docs](https://pleets.org)[ RSS](/packages/pleets-php-event-dispatcher/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

PSR-14 Event Dispatcher
=======================

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

[![Quality Gate Status](https://camo.githubusercontent.com/47e4c433d622f8c442a35f0b27e7e29887f7b54cce11ccbe837a028fbe6d15f7/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d706c656574735f7068702d6576656e742d64697370617463686572266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=pleets_php-event-dispatcher)

Event Dispatching is a common and well-tested mechanism to allow developers to inject logic into an application easily and consistently. This library was developed according to PSR-14 and all interfaces in psr/event-dispatcher were implemented.

You can download this project as follows.

```
git clone git@github.com:pleets/php-event-dispatcher.git
```

Usage
=====

[](#usage)

Creating Events
---------------

[](#creating-events)

An Event is a message produced by an Emitter. It may be any arbitrary PHP object. You can create an event extending the `Event` class.

```
use Pleets\EventDispatcher\Event;

class DepositEvent extends Event
{
    public string $text;
    protected string $amount;
    private string $currency = 'USD';

    public function __construct($amount)
    {
        $this->amount = $amount;
        $this->text = 'We are preparing your deposit: '.$this->amount.$this->currency;
    }
}
```

Creating Listeners
------------------

[](#creating-listeners)

A Listener is any PHP callable that expects to be passed an Event. Zero or more Listeners may be passed the same Event. A Listener MAY enqueue some other asynchronous behavior if it so chooses. You can create a listener extending the `Listener` class.

```
use Pleets\EventDispatcher\Event;
use Pleets\EventDispatcher\Listener;

class SendDepositNotification extends Listener
{
    public function handle(Event $event): void
    {
        $event->text = 'Your deposit was done!';
    }
}
```

Creating Listener Providers and subscribing events
--------------------------------------------------

[](#creating-listener-providers-and-subscribing-events)

A Listener Provider is responsible for determining what Listeners are relevant for a given Event, but MUST NOT call the Listeners itself. A Listener Provider may specify zero or more relevant Listeners. You can create a listener provider as follows.

```
$provider = new ListenerProvider();

$deposit = new DepositEvent('127.00');
$provider->subscribe($deposit, new SendDepositNotification());
```

Dispatching your events
-----------------------

[](#dispatching-your-events)

A Dispatcher is a service object that is given an Event object by an Emitter. The Dispatcher is responsible for ensuring that the Event is passed to all relevant Listeners, but MUST defer determining the responsible listeners to a Listener Provider. You can dispatch you events as follows.

```
$dispatcher = new Dispatcher($provider);
$dispatcher->dispatch($deposit);
```

All listeners will be informed about this event and will be executed.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2116d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/da87983fc787b1876917187cf3f37a66659e1e3f81ff5fec88cd43b6140a1bda?d=identicon)[fermius](/maintainers/fermius)

---

Top Contributors

[![darioriverat](https://avatars.githubusercontent.com/u/5879790?v=4)](https://github.com/darioriverat "darioriverat (43 commits)")

---

Tags

phppsr-14event dispatcher

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pleets-php-event-dispatcher/health.svg)

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

###  Alternatives

[phly/phly-event-dispatcher

Experimental event dispatcher for PSR-14

26209.9k4](/packages/phly-phly-event-dispatcher)

PHPackages © 2026

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