PHPackages                             phly/phly-event-emitter - 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. phly/phly-event-emitter

Abandoned → [phly/phly-event-dispatcher](/?search=phly%2Fphly-event-dispatcher)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

phly/phly-event-emitter
=======================

PSR-14 event emitter

0.1.0(7y ago)441[1 PRs](https://github.com/phly/phly-event-emitter/pulls)BSD-3-ClausePHPPHP ^7.1

Since Aug 3Pushed 9mo ago1 watchersCompare

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

READMEChangelogDependencies (6)Versions (3)Used By (0)

phly-event-emitter
==================

[](#phly-event-emitter)

> ⚠️ **Archived 2025-08-17**
>
> Use at your own risk.

[![Build Status](https://camo.githubusercontent.com/669f29e4f9973838c492fbfae2013bae58edf3bfca3172e9ae421dce6511581f/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f70686c792f70686c792d6576656e742d656d69747465722e7376673f6272616e63683d6d6173746572)](https://secure.travis-ci.org/phly/phly-event-emitter)[![Coverage Status](https://camo.githubusercontent.com/2721baf0bc83d3b9f3149e44c1e03fc2f12a32d0b312fc6f16bd6bc64df562da/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70686c792f70686c792d6576656e742d656d69747465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/phly/phly-event-emitter?branch=master)

> ## Experimental!
>
> [](#experimental)
>
> This library is experimental, tracking different iterations and experiments being proposed for PSR-14. It is highly unstable in terms of API; use at your own risk.

This library provides an implementation of the following proposed PSR-14 interfaces:

- `ListenerProvider` implements `ListenerProviderInterface`, and allows you to attach listeners to any message type. It then acts as a generator, looping through each listener and testing if it handles the message type.
- `PrioritizedListenerProvider` also implements `ListenerProviderInterface`, and allows you to attach listeners to any message type, with an integer *priority*. When listeners are retrieved, it loops through all attached listeners, and injects those capable of listening to the emitted message to a priority queue, which it then returns.
- `MessageNotifier` implements `MessageNotifierInterface`, and accepts a `ListenerProviderInterface` to its constructor. It then loops through and notifies listeners returned for the message. If any listeners throw exceptions, it catches them, and, when all listeners have been notified, throws a `Phly\EventEmitter\Exception\ExceptionAggregate` that aggregates all of them; call the `getListenerExceptions()` method of that class to iterate through them.
- `TaskProcessor` implements `TaskProcessorInterface`, and accepts a `ListenerProviderInterface` to its constructor. It then loops through and processes listeners returned for the task, halting early if the task is stoppable and indicates propagation has been stopped. Exceptions thrown by listeners are not caught.

It DOES NOT provide implementations for the following interfaces:

- `EventInterface` (consumers will create these)
- `MessageInterface` (consumers will create these)
- `TaskInterface` (consumers will create these)
- `StoppableTaskInterface` (consumers will create these)

Installation
------------

[](#installation)

You will first need to add a repository entry to your `composer.json`:

```
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/phly/phly-event-emitter.git"
    }
],
```

Then, run the following to install this library:

```
$ composer require phly/phly-event-emitter
```

Documentation
-------------

[](#documentation)

### Basic usage

[](#basic-usage)

The following demonstrates using the `ListenerProvider` to attach a listener. The provider is then used to seed either a `MessageNotifier` or `TaskProcessor`.

```
use Phly\EventEmitter\MessageNotifier;
use Phly\EventEmitter\ListenerProvider;

$listeners = new ListenerProvider();
$listeners->on(BootstrapEvent::class, function ($e) {
    // do something with the bootstrap event
});

$notifier = new MessageNotifier($listeners);
$notifier->notify(new BootstrapEvent($params));
```

### Prioritized listeners

[](#prioritized-listeners)

The following example uses a `PrioritizedListenerProvider` to provide three different listeners, each with a different priority. Priorities are integers; higher priorities execute first, while lower priorities (including *negative*priorities) execute last.

```
use Phly\EventEmitter\TaskProcessor;
use Phly\EventEmitter\PrioritizedListenerProvider;

$listeners = new PrioritizedListenerProvider();
$listeners->on(BootstrapTask::class, function ($e) {
    echo 1, PHP_EOL;
}, -100);
$listeners->on(BootstrapTask::class, function ($e) {
    echo 2, PHP_EOL;
}, 100);
$listeners->on(BootstrapTask::class, function ($e) {
    echo 3, PHP_EOL;
}, 1);

$processor = new TaskProcessor($listeners);
$processor->process(new BootstrapTask($params));
```

In the above, the output will become:

```
2
3
1

```

Support
-------

[](#support)

- [Issues](https://github.com/phly/phly-event-emitter/issues/)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance42

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

2738d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25943?v=4)[Matthew Weier O'Phinney](/maintainers/weierophinney)[@weierophinney](https://github.com/weierophinney)

---

Top Contributors

[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (7 commits)")

---

Tags

eventpsr-14

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phly-phly-event-emitter/health.svg)

```
[![Health](https://phpackages.com/badges/phly-phly-event-emitter/health.svg)](https://phpackages.com/packages/phly-phly-event-emitter)
```

###  Alternatives

[doctrine/event-manager

The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.

6.1k501.1M115](/packages/doctrine-event-manager)[psr/event-dispatcher

Standard interfaces for event handling.

2.3k618.8M865](/packages/psr-event-dispatcher)[league/event

Event package

1.6k141.6M184](/packages/league-event)[crell/tukio

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

112183.8k13](/packages/crell-tukio)

PHPackages © 2026

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