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

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

systream/event-dispatcher
=========================

Observer for events

1.0.3(9y ago)07281MITPHPPHP &gt;=5.4.0

Since May 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/systream/event-dispatcher)[ Packagist](https://packagist.org/packages/systream/event-dispatcher)[ RSS](/packages/systream-event-dispatcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (1)

Event dispatcher
================

[](#event-dispatcher)

Observer for events

Usage Examples
--------------

[](#usage-examples)

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

[](#installation)

You can install this package via [packagist.org](https://packagist.org/packages/systream/event-dispatcher) with [composer](https://getcomposer.org/).

`composer require systream/event-dispatcher`

composer.json:

```
"require": {
    "systream/event-dispatcher": "1.*"
}
```

This library requires `php 5.6` or higher, but also works on php 5.4.

### Subscribe to event

[](#subscribe-to-event)

```
$eventDispatcher = new EventDispatcher();

$subscription = new EventDispatcher\Subscription('nameOfEvent', function (EventInterface $event) {
	// do stuff here
});
$eventDispatcher->subscribe($subscription);
```

### Fire an event

[](#fire-an-event)

```
$eventDispatcher = new EventDispatcher();
$eventDispatcher->emit(new EventDispatcher\Event('nameOfEvent'));
```

### Stop Propagation

[](#stop-propagation)

```
$eventDispatcher = new EventDispatcher();

$subscription = new EventDispatcher\Subscription('fooBar', function (EventDispatcher\EventInterface $event) {
	$event->stopPropagation();
});
$eventDispatcher->subscribe($subscription);

$subscription2 = new EventDispatcher\Subscription('fooBar', function (EventDispatcher\EventInterface $event) {
	// do stuff here
});
$eventDispatcher->subscribe($subscription2);

$eventDispatcher->emit(new EventDispatcher\Event('fooBar'));
```

In this case the second subscription won't be invoked.

### Custom events

[](#custom-events)

The only thing you need to do is that implementing the `EventInterface`

```
class MyCustomEvent extends AbstractEvent implements EventInterface
{

	/**
	 * @var string
	 */
	protected $key = 'order.save';

	/**
	 * @var Order
	 */
	protected $order;

	/**
	 * @param string $key
	 */
	public function __construct(Order $order)
	{
		$this->order = $order;
	}

	/**
	 * @return Order
	 */
	public function getOrder()
	{
		return $this->order;
	}
}

...

$eventDispatcher = new EventDispatcher();
$subscription = new EventDispatcher\Subscription('nameOfEvent', function (OrderEvent $event) {
	$order = $orderEvent->getOrder();
	// do stuff
});
$eventDispatcher->subscribe($subscription);
```

### Custom Subscriptions

[](#custom-subscriptions)

The only thing you need to do is that implementing the `SubscriptionInterface`

Test
----

[](#test)

[![Build Status](https://camo.githubusercontent.com/5e00b0a1e404b7c7b3d053285d9df9f0547b70e651c77e5ad1739110b3372aa4/68747470733a2f2f7472617669732d63692e6f72672f737973747265616d2f6576656e742d646973706174636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/systream/event-dispatcher)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

3618d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c5ea6e7d8143a1fba541e1f41419cf36a4f970806d4bd91094d3b46177aea6d?d=identicon)[systream](/maintainers/systream)

---

Top Contributors

[![systream](https://avatars.githubusercontent.com/u/1583029?v=4)](https://github.com/systream "systream (8 commits)")

---

Tags

eventobserverdispatcher

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[contributte/event-dispatcher

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

292.4M19](/packages/contributte-event-dispatcher)

PHPackages © 2026

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