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

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

shieldon/event-dispatcher
=========================

Event dispatcher for PHP.

1.0.0(5y ago)624.7k↑27.6%22MITPHPPHP &gt;=7.1.0CI failing

Since Aug 14Pushed 5y ago3 watchersCompare

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

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

PHP Event Dispatcher
====================

[](#php-event-dispatcher)

[![Build Status](https://camo.githubusercontent.com/60cf7b5d4e9c59cd79d903d5bc12c65889e532ea7f667e407781470f3e186c80/68747470733a2f2f7472617669732d63692e6f72672f74657272796c696e6f6f6f2f6576656e742d646973706174636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/terrylinooo/event-dispatcher) [![codecov](https://camo.githubusercontent.com/96a4d23e9584b43ffef89602eacb7e2793dc06d489f4cfeb58e586ad407656b3/68747470733a2f2f636f6465636f762e696f2f67682f74657272796c696e6f6f6f2f6576656e742d646973706174636865722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/terrylinooo/event-dispatcher) [![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

This package is designed as a part of [Shieldon Firewall 2](https://github.com/terrylinooo/shieldon). You can also use it on your projects as well.

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

[](#installation)

Use PHP Composer:

```
composer require shieldon/event-dispatcher
```

Or, download it and include the Shieldon autoloader.

```
require 'autoload.php';
```

Usage
-----

[](#usage)

### Add a Listener

[](#add-a-listener)

```
/**
 * @param string        $name      The name of an event.
 * @param string|array  $func      Callable function or class.
 * @param int           $priority  The execution priority.
 *
 * @return bool
 */
\Shieldon\Event\Event::addLister(string $name, $func, int $priority = 10): bool
```

Please note, the **priority** must be **unique**. This method returns true when add a listener, false when the prirotiy has been taken by another listener.

### Dispatch

[](#dispatch)

```
/**
 * @param string $name The name of an event.
 * @param array  $args The arguments.
 *
 * @return mixed
 */
\Shieldon\Event\Event::doDispatch(string $name, array $args = []): mixed
```

Return the filtered result, it's similar to WordPress' filter. You can ignore the return if you don't need that.

Example
-------

[](#example)

### Closure

[](#closure)

Add a listener.

```
\Shieldon\Event\Event::addListener('test_1', function() {
    echo 'This is a closure function call.';
});
```

Dispatch.

```
$result = \Shieldon\Event\Event::doDispatch('test_1');
```

### Function

[](#function)

Function for listener.

```
function test_event_disptcher()
{
    echo 'This is a function call.';
}
```

Add a listener.

```
\Shieldon\Event\Event::addListener('test_2', 'test_event_disptcher');
```

Dispatch.

```
$result = \Shieldon\Event\Event::doDispatch('test_2');
```

### Class

[](#class)

Add a listener.

```
$example = new Example();

\Shieldon\Event\Event::addListener('test_3', [$example, 'example1']);
```

Dispatch.

```
$result = \Shieldon\Event\Event::doDispatch('test_3');
```

Hope this helps.

---

#### Author

[](#author)

- [Terry L.](https://terryl.in)

#### License

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

2104d ago

### Community

Maintainers

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

---

Top Contributors

[![terrylinooo](https://avatars.githubusercontent.com/u/11989371?v=4)](https://github.com/terrylinooo "terrylinooo (2 commits)")

---

Tags

eventHOOKdispatcherwordpress-filter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[contributte/event-dispatcher

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

292.4M19](/packages/contributte-event-dispatcher)[pagon/eventemitter

Event Emitter for PHP

2919.3k3](/packages/pagon-eventemitter)

PHPackages © 2026

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