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

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

hoa/event
=========

The Hoa\\Event library.

2.17.08.30(8y ago)32123.5M—0.3%12[2 issues](https://github.com/hoaproject/Event/issues)[2 PRs](https://github.com/hoaproject/Event/pulls)17BSD-3-ClausePHPPHP &gt;=7.1

Since Nov 23Pushed 5y ago4 watchersCompare

[ Source](https://github.com/hoaproject/Event)[ Packagist](https://packagist.org/packages/hoa/event)[ Docs](https://hoa-project.net/)[ RSS](/packages/hoa-event/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (17)

 [![Hoa](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)

---

 [![Build status](https://camo.githubusercontent.com/72a312cbef8b7a52d23969d71e5f73a81a13a185b411137d503b4148d9ba98ca/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686f6170726f6a6563742f4576656e742f6d61737465722e737667)](https://travis-ci.org/hoaproject/Event) [![Code coverage](https://camo.githubusercontent.com/3165b7958b3a4378f598f7aa64334070edb8bee5d6ef2a8cd8769795cbd05610/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f686f6170726f6a6563742f4576656e742f6d61737465722e737667)](https://coveralls.io/github/hoaproject/Event?branch=master) [![Packagist](https://camo.githubusercontent.com/9bdcda66fa86a7725191aa628f6ff8ffe072d1ee23906b76a3ea7db2e6a36aef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686f612f6576656e742e737667)](https://packagist.org/packages/hoa/event) [![License](https://camo.githubusercontent.com/a3daaaf0e162bf610ee0340aba8e2f021bd76d82d889e9026a9a73bdf333f8a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686f612f6576656e742e737667)](https://hoa-project.net/LICENSE)

 Hoa is a **modular**, **extensible** and **structured** set of PHP libraries.
 Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\\Event
==========

[](#hoaevent)

[![Help on IRC](https://camo.githubusercontent.com/4dbc9c9d28c30cf1ab591f4bb8212fe4dbddc734145df532a9bb86b09878d4c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d253233686f6170726f6a6563742d6666303036362e737667)](https://webchat.freenode.net/?channels=#hoaproject)[![Help on Gitter](https://camo.githubusercontent.com/8c4c85951788ff606b1268cb3dd946be05e3054795455d0a7b9250711bc2ac05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d6769747465722d6666303036362e737667)](https://gitter.im/hoaproject/central)[![Documentation](https://camo.githubusercontent.com/7059ad5f1a363f9098686c59d432f01d7330aed9d4b6c8111d985fd64cfc6c60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63756d656e746174696f6e2d6861636b5f626f6f6b2d6666303036362e737667)](https://central.hoa-project.net/Documentation/Library/Event)[![Board](https://camo.githubusercontent.com/fd81654ba14b3aca3a713e1b471bc3fc3ba7b5bb3761ccffd6eea2e2ed1fa5ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f7267616e69736174696f6e2d626f6172642d6666303036362e737667)](https://waffle.io/hoaproject/event)

This library allows to use events and listeners in PHP. This is an observer design-pattern implementation.

[Learn more](https://central.hoa-project.net/Documentation/Library/Event).

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

[](#installation)

With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`hoa/event`](https://packagist.org/packages/hoa/event):

```
$ composer require hoa/event '~2.0'
```

For more installation procedures, please read [the Source page](https://hoa-project.net/Source.html).

Testing
-------

[](#testing)

Before running the test suites, the development dependencies must be installed:

```
$ composer install
```

Then, to run all the test suites:

```
$ vendor/bin/hoa test:run
```

For more information, please read the [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html).

Quick usage
-----------

[](#quick-usage)

We propose a quick overview of how to use events and listeners.

### Events

[](#events)

An event is:

- **Asynchronous** when registering, because the observable may not exist yet while observers start to observe,
- **Anonymous** when using, because the observable has no idea how many and what observers are observing,
- It aims at a **large** diffusion of data through isolated components. Wherever is the observable, we can observe its data.

In Hoa, an event channel has the following form: `hoa://Event/LibraryName/AnId:pseudo-class#anAnchor`. For instance, the `hoa://Event/Exception` channel contains all exceptions that have been thrown. The `hoa://Event/Stream/StreamName:close-before` contains all streams that are about to close. Thus, the following example will observe all thrown exceptions:

```
Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    function (Hoa\Event\Bucket $bucket) {
        var_dump(
            $bucket->getSource(),
            $bucket->getData()
        );
    }
);
```

Because `attach` expects a callable and because Hoa's callable implementation is smart, we can directly attach a stream to an event, like:

```
Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    new Hoa\File\Write('Foo.log')
);
```

This way, all exceptions will be printed on the `Foo.log` file.

### Listeners

[](#listeners)

Contrary to an event, a listener is:

- **Synchronous** when registering, because the observable must exist before observers can observe,
- **Identified** when using, because the observable knows how many observers are observing,
- It aims at a **close** diffusion of data. The observers must have an access to the observable to observe.

The `Hoa\Event\Listenable` interface requires the `on` method to be present to register a listener to a listener ID. For instance, the following example listens the `message` listener ID, i.e. when a message is received by the WebSocket server, the closure is executed:

```
$server = new Hoa\Websocket\Server(…);
$server->on('message', function (Hoa\Event\Bucket $bucket) {
    var_dump(
        $bucket->getSource(),
        $bucket->getData()
    );
});
```

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

[](#documentation)

The [hack book of `Hoa\Event`](https://central.hoa-project.net/Documentation/Library/Event) contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

```
$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open
```

More documentation can be found on the project's website: [hoa-project.net](https://hoa-project.net/).

Getting help
------------

[](#getting-help)

There are mainly two ways to get help:

- On the [`#hoaproject`](https://webchat.freenode.net/?channels=#hoaproject)IRC channel,
- On the forum at [users.hoa-project.net](https://users.hoa-project.net).

Contribution
------------

[](#contribution)

Do you want to contribute? Thanks! A detailed [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html) explains everything you need to know.

License
-------

[](#license)

Hoa is under the New BSD License (BSD-3-Clause). Please, see [`LICENSE`](https://hoa-project.net/LICENSE) for details.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity66

Solid adoption and visibility

Community26

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88.4% 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 ~129 days

Recently: every ~149 days

Total

6

Last Release

3183d ago

Major Versions

0.15.11.23 → 1.16.01.112016-01-11

1.17.01.13 → 2.17.08.302017-08-30

### Community

Maintainers

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

---

Top Contributors

[![Hywan](https://avatars.githubusercontent.com/u/946104?v=4)](https://github.com/Hywan "Hywan (38 commits)")[![Metalaka](https://avatars.githubusercontent.com/u/5406767?v=4)](https://github.com/Metalaka "Metalaka (3 commits)")[![vonglasow](https://avatars.githubusercontent.com/u/1275202?v=4)](https://github.com/vonglasow "vonglasow (2 commits)")

---

Tags

eventhoalibrarylistenerobserverphpeventlibrarylistenerobserver

### Embed Badge

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

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

###  Alternatives

[league/event

Event package

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

Library for event-based development

29760.0k5](/packages/jbzoo-event)[supervisorphp/event

Listen to Supervisor events in PHP

1442.4k](/packages/supervisorphp-event)

PHPackages © 2026

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