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

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

brick/event
===========

Event dispatching library

0.1.1(6y ago)2211.6k↓41.7%33MITPHPPHP &gt;=7.1

Since Sep 11Pushed 2y ago3 watchersCompare

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

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

Brick\\Event
============

[](#brickevent)

[![](https://raw.githubusercontent.com/brick/brick/master/logo.png)](https://raw.githubusercontent.com/brick/brick/master/logo.png)

A simple event dispatching mechanism.

[![Build Status](https://github.com/brick/event/workflows/CI/badge.svg)](https://github.com/brick/event/actions)[![Coverage Status](https://camo.githubusercontent.com/b331ff943afcaf318625d517c8dd931e27c97d7fb429add95868d97391b480cb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f627269636b2f6576656e742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/brick/event?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/6d4694ab91118c28e431fa2aaf92965e22a7c0dc98e9dbcb415d78a5063eb1bc/68747470733a2f2f706f7365722e707567782e6f72672f627269636b2f6576656e742f762f737461626c65)](https://packagist.org/packages/brick/event)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](http://opensource.org/licenses/MIT)

Introduction
------------

[](#introduction)

This library helps to write extensible software by plugging in external listeners to events dispatched by an application.

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

[](#installation)

This library is installable via [Composer](https://getcomposer.org/):

```
composer require brick/event
```

Requirements
------------

[](#requirements)

This library requires PHP 7.1 or later.

Overview
--------

[](#overview)

This package provides the `EventDispatcher`. The dispatcher dispatches *events*: an event is a unique `string` along with optional parameters. The events are intercepted by *listeners*: any `callable` can be an event listener.

### Basic usage

[](#basic-usage)

Let's instantiate a dispatcher:

```
use Brick\Event\EventDispatcher;

$dispatcher = new EventDispatcher();

```

And add a few listeners:

```
$dispatcher->addListener('startup', function() {
    echo 'Caught startup event';
});

$dispatcher->addListener('shutdown', function() {
    echo 'Caught shutdown event';
});

```

Now, let's dispatch some events:

```
$dispatcher->dispatch('startup'); // will display "Caught startup event"
$dispatcher->dispatch('shutdown'); // will display "Caught shutdown event"

```

Any additional parameters you pass to `dispatch()` are forwarded to the listeners:

```
$dispatcher->addListener('test', function($a, $b) {
    echo "Caught $a and $b";
});

$dispatcher->dispatch('test', 'Hello', 'World'); // will display "Caught Hello and World"

```

### Setting priorities

[](#setting-priorities)

By default, the listeners are called in the order they have been registered. It is possible to bypass this natural order by passing a priority to `addListener()`:

```
$dispatcher->addListener('startup', function() { ... }, 10);

```

The default priority is `0`. The listeners with the highest priority will be called first in the chain. Two listeners with the same priority will be called in the order they have been registered.

### Stopping event propagation

[](#stopping-event-propagation)

Any listener can decide that the event should not be propagated to further listeners in the chain, by returning `false`:

```
$dispatcher->addListener('startup', function() {
    // ...

    return false;
});

```

The dispatcher will then break the chain and no further listeners will be called for this event.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community15

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

Total

2

Last Release

2358d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57189121968030f0770811b461cc92f9c19c08f5c4767292f2ede48b7277cfad?d=identicon)[BenMorel](/maintainers/BenMorel)

---

Top Contributors

[![BenMorel](https://avatars.githubusercontent.com/u/1952838?v=4)](https://github.com/BenMorel "BenMorel (62 commits)")

---

Tags

event-dispatchereventsphpeventbrickeventdispatcher

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[league/event

Event package

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

Money and currency library

1.9k37.9M102](/packages/brick-money)[laminas/laminas-eventmanager

Trigger and listen to events within a PHP application

1.0k69.8M225](/packages/laminas-laminas-eventmanager)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)

PHPackages © 2026

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