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

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

effectra/event-dispatcher
=========================

The Effectra Event Dispatcher package.

v1.1.0(2y ago)0252MITPHP

Since Oct 27Pushed 2y agoCompare

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

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

Effectra Event Dispatcher
=========================

[](#effectra-event-dispatcher)

**Effectra\\EventDispatcher** is a versatile and lightweight event dispatching library for PHP, designed to simplify the management of events within your application. It adheres to the PSR-14 standard, providing a consistent and extensible way to handle events, listeners, and event propagation.

Features
--------

[](#features)

- **PSR-14 Compliance:** Follows the PSR-14 standard for event dispatching, ensuring interoperability with other PHP packages and frameworks.
- **Stoppable Events:** Supports stoppable events, allowing events to be halted during propagation if necessary.
- **Flexible Listener Providers:** Easily register and manage listeners for specific events through a flexible listener provider interface.
- **Consistent Event Handling:** Ensures synchronous execution of listeners in the order they are registered.
- **Simplified API:** Provides a straightforward API for dispatching events, making it easy to integrate into your projects.

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

[](#installation)

You can install **Effectra\\EventDispatcher** via Composer. Run the following command in your project directory:

```
composer require effectra/event-dispatcher
```

Usage
-----

[](#usage)

### 1. Creating Events

[](#1-creating-events)

Create your custom event classes by extending the `Effectra\EventDispatcher\Event` class. This base class implements the `Psr\EventDispatcher\StoppableEventInterface`, allowing events to be stoppable.

```
namespace YourNamespace\Events;

use Effectra\EventDispatcher\Event;

class CustomEvent extends Event
{
    // Your event properties and methods
}
```

### 2. Registering Listeners

[](#2-registering-listeners)

Create listeners by defining callable functions or classes implementing the necessary logic. Register listeners using the `Effectra\EventDispatcher\ListenerProvider` class.

```
namespace YourNamespace;

use Effectra\EventDispatcher\ListenerProvider;
use YourNamespace\Events\CustomEvent;

// Create a listener provider
$listenerProvider = new ListenerProvider();

// Register a listener for the CustomEvent
$listenerProvider->addListener(CustomEvent::class, function (CustomEvent $event) {
    // Handle the CustomEvent
});

// Dispatching the event
$event = new CustomEvent();
$dispatcher = new EventDispatcher($listenerProvider);
$dispatcher->dispatch($event);
```

### 3. Stoppable Events

[](#3-stoppable-events)

To create a stoppable event, use the `stopPropagation()` method within your event logic. This will prevent further listeners from being executed.

```
namespace YourNamespace\Events;

use Effectra\EventDispatcher\Event;

class StoppableEvent extends Event
{
    public function process(): void
    {
        // Your event processing logic

        // Stop further propagation if a condition is met
        if ($condition) {
            $this->stopPropagation();
        }
    }
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! Fork the repository, create a branch, make your changes, and then create a pull request. Please ensure your PR description clearly describes the changes you made.

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

912d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

composereventevent-dispatcherphppsr-14

### Embed Badge

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

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

###  Alternatives

[symfony/event-dispatcher-contracts

Generic abstractions related to dispatching event

3.4k756.5M423](/packages/symfony-event-dispatcher-contracts)[league/event

Event package

1.6k141.6M184](/packages/league-event)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[yohang/finite

A simple PHP Finite State Machine

1.3k3.5M10](/packages/yohang-finite)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)

PHPackages © 2026

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