PHPackages                             aesonus/events - 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. aesonus/events

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

aesonus/events
==============

v0.2(7y ago)018PHPPHP &gt;=7.1

Since Jul 9Pushed 6y agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c9d8792dddcc71ac29d506c87381a8c458b7b853344762503c34b9a06f0f9864/68747470733a2f2f7472617669732d63692e6f72672f4165736f6e75732f6576656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Aesonus/events)

Events
======

[](#events)

A simple Event, Listener,and Dispatcher

Tests
-----

[](#tests)

phpunit

How to use
----------

[](#how-to-use)

Create a dispatcher

```
$dispatcher = new Dispatcher();
```

Extend the base event class for each of your events:

```
class MyEvent extends Event { }
```

Implement listener interface for each of your events and listeners

```
class MyListener implements ListenerInterface {
    ...

```

Implement the handle method in listener to do a specific task:

```
    ...
    public function handle(EventInterface $event): void { }
}
```

Attach listeners to event(s) in a queue:

```
$event = new MyEvent();

$event->attach(new MyListener());
```

You can assign priorities to listeners as well. The default priority is 0.

```
$event->attach(new MyListener(), 3);
```

You can attach multiple listeners using an array.

```
$listeners = [new MyListener(),new MyListener(),new MyListener()];
$event->attach($listeners);
```

Each listener attached will be assigned the given priority:

```
$listeners = [new MyListener(),new MyListener(),new MyListener()];

//They all get a priority of 3
$event->attach($listeners, 3);
```

Note that if the listeners all have the same priority, the queue will start at the first element of the first attached listener(s). Consider the following code:

```
$listenersA = [new MyListenerA(),new MyListenerB()];
$event->attach($listenersA);

$listenersB = [new MyListenerC(),new MyListenerD()];
$event->attach($listenersB);
```

When this event is dispatched, the first listener to receive the event will be MyListenerA.

You can also override the default priority by passing the listener in a numbered array with the element at index 0 is the listener and the element at index 1 is the priority:

```
$listeners = [new MyListener(),[new MyListener(), 2],new MyListener()];

//They all get a priority of 3, except for the the listener at index 1
$event->attach($listeners, 3);
```

Please note that all priorities must be integers. Priorities provided through the array interface that are not integers will be set to the default priority.

Register events with dispatcher

```
$dispatcher->register($event);
```

Dispatch events with class name. This will call the handle method on each listener in the priority queue.

```
$dispatcher->dispatch(MyEvent::class);
```

You can also dispatch an event without the help of a dispatcher:

```
$event->dispatch();
```

The dispatch queue can be interrupted by an exception and resume where it left off.

```
try {
    $event->dispatch(); // This will throw an exception from one of the listeners
} catch (ResumableException $ex) {
    //do stuff to make all better
}

//Resume the dispatch
$event->dispatch();
...
```

The dispatch queue may also be reset to the state it was in just before dispatch() is called:

```
$event->reset();
```

It is important to note that resuming execution of the event queue will change the cached copy of the queue. Use resumability with care.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Every ~5 days

Total

3

Last Release

2855d ago

Major Versions

v0.2 → v2.0-beta2018-07-20

### Community

Maintainers

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

---

Top Contributors

[![Aesonus](https://avatars.githubusercontent.com/u/24643115?v=4)](https://github.com/Aesonus "Aesonus (20 commits)")

### Embed Badge

![Health badge](/badges/aesonus-events/health.svg)

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

###  Alternatives

[64robots/nova-fields

A Laravel Nova field.

2841.0M4](/packages/64robots-nova-fields)[outl1ne/nova-color-field

A Laravel Nova Color Picker field.

26249.4k](/packages/outl1ne-nova-color-field)[mremi/contact-bundle

Implementation of a contact form for Symfony2

2712.4k2](/packages/mremi-contact-bundle)[tlr/html-table-builder

An HTML Table Builder

1040.1k](/packages/tlr-html-table-builder)[phpstrap/phpstrap

Bootstrap layout generator

1214.7k](/packages/phpstrap-phpstrap)

PHPackages © 2026

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