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

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

splot/event-manager
===================

Event manager.

1.0.1(6y ago)01.5k1MITPHPPHP &gt;=5.3.3

Since Oct 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/splot/EventManager)[ Packagist](https://packagist.org/packages/splot/event-manager)[ RSS](/packages/splot-event-manager/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

Splot Event Manager
===================

[](#splot-event-manager)

Simple event manager for PHP.

[![Build Status](https://camo.githubusercontent.com/cb818a17173c6f1375ed35e5bfec6c5949c8128aaa8325e74c16369bc74ef64f/68747470733a2f2f7472617669732d63692e6f72672f73706c6f742f4576656e744d616e616765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/splot/EventManager)[![SensioLabsInsight](https://camo.githubusercontent.com/381e0f64c524a6574068234cbb5c81019077df726eb4e1c3ae30476ff1975711/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35653139346531382d386335352d343833622d613337362d3234333934336562373662382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/5e194e18-8c55-483b-a376-243943eb76b8)[![HHVM Status](https://camo.githubusercontent.com/5eb0dc95ca76ad7aed5945996fffff1d8a779eaf06d87833d40f15d107490a7e/687474703a2f2f6868766d2e683463632e64652f62616467652f73706c6f742f6576656e742d6d616e616765722e706e67)](http://hhvm.h4cc.de/package/splot/event-manager)

Features
--------

[](#features)

- Stop further propagation of events / stop other listeners from being called.
- Mark in the event that default action should be prevented.
- All events are classes and objects.

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

[](#installation)

You can install Splot Event Manager using [Composer](https://getcomposer.org/).

```
$ composer require splot/event-manager dev-master

```

All you need to do to start using it is instantiation:

```
$eventManager = new \Splot\EventManager\EventManager();

```

You can optionally pass a `Psr\Log\LoggerInterface` to the constructor for debug messages.

Events
------

[](#events)

In Splot Event Manager every event is an instance of a class that extends `Splot\EventManager\AbstractEvent`. It means that every event name is set in that event class (by default and convention an event name is its full namespaced class name) and actual event objects are passed to all listeners. They may or may not contain any additional data and it's fully responsibility of the code that triggers an event to populate it with data.

If you want to use an event name (e.g. to register a listener) it is best practice to get it from the event class static method `::getName()`.

By convention, all events should be read-only, so it is best to pass any data to them in their constructors and not allow for it to be altered at later time (e.g. by storing them in `protected` or `private` attributes and not creating setters for them).

Triggering events
-----------------

[](#triggering-events)

To trigger an event you need to just call `EventManager::trigger()` method with the event instance.

```
$eventManager->trigger(new MyEvent());

```

This method returns `boolean` for convenience checking if a default action that follows the event should be executed or not. See below for details.

Listening for events
--------------------

[](#listening-for-events)

To listen for an event you can subscribe a `callable` (most usually a closure). The listener is then called with a single argument - the event instance.

```
$eventManager->subscribe(MyEvent::getName(), function($event) {
    // do something
});

```

#### Listener priority

[](#listener-priority)

Listeners are called in the order they were registered, but you can subscribe listeners with a priority (higher priority means that they will be executed first). By default, the priority is `0`, but it can be both positive and negative.

Simply pass the listener priority as 3rd (last) argument of the `::subscribe()` method.

```
$eventManager->subscribe(MyEvent::getName(), function($event) {
    // listener one
}, -20);

$eventManager->subscribe(MyEvent::getName(), function($event) {
    // listener two
}, 30);

```

In the example above, the second listener will be executed first when `MyEvent` is triggered.

Other
-----

[](#other)

#### Stopping propagation

[](#stopping-propagation)

When listening for an event you can also prevent it from calling other subsequent listeners.

```
$event->stopPropagation()

```

Calling this method will let the Event Manager know that no further listeners should be notified about the `$event`.

#### Preventing default action

[](#preventing-default-action)

The event can let the triggering code know that default action that follows it should not be executed. This is simply done by calling

```
$event->preventDefault()

```

or by returning `false` from a listener.

The triggering code can then check on the event instance:

```
$eventManager->trigger($event);
if (!$event->isDefaultPrevented()) {
    // do something that is suppose to happen
}

```

For convenience, the `EventManager::trigger()` method also returns information whether or not the default action should be prevented (it returns `true` if default has not been prevented). The above example can be written like this:

```
if ($eventManager->trigger($event)) {
    // do something that is suppose to happen
}

```

Contribute
----------

[](#contribute)

Issues and pull requests are very welcome! When creating a pull request please include full test coverage to your changes.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~1980 days

Total

2

Last Release

2307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e89b36fde2bd70a04676729659be470926438b5c2b37d6393f7a965c09110be?d=identicon)[splot](/maintainers/splot)

---

Top Contributors

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

---

Tags

eventdispatchersubscriberpubsubpublisher

### Embed Badge

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

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

###  Alternatives

[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[contributte/event-dispatcher

Best event dispatcher / event manager / event emitter for Nette Framework

292.5M19](/packages/contributte-event-dispatcher)[tomaj/hermes

Simple php background processing library

38258.0k7](/packages/tomaj-hermes)

PHPackages © 2026

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