PHPackages                             monkeyscloud/monkeyslegion-events - 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. [Framework](/categories/framework)
4. /
5. monkeyscloud/monkeyslegion-events

ActiveLibrary[Framework](/categories/framework)

monkeyscloud/monkeyslegion-events
=================================

PSR-14 event-bus for MonkeysLegion core lifecycle events

1.0.1(5mo ago)11.0k↑142.9%2MITPHPPHP ^8.4

Since Jul 24Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Events)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-events)[ RSS](/packages/monkeyscloud-monkeyslegion-events/feed)WikiDiscussions main Synced 1mo ago

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

MonkeysLegion • Event Dispatcher (PSR-14)
=========================================

[](#monkeyslegion--event-dispatcher-psr-14)

A **zero-dependency**, PSR-14-compatible event-bus for MonkeysLegion projects.
It ships with:

PackagePurpose`MonkeysLegion\Events\ListenerProvider`Keeps listeners, supports **priority &amp; once**`MonkeysLegion\Events\EventDispatcher`Tiny dispatcher that just calls the listenersBecause the code is only a few hundred lines you can drop it in, skim it, and *understand* every line – no black-box magic ✨.

---

📦 Installation
--------------

[](#-installation)

```
composer require monkeyscloud/monkeyslegion-events
```

(If you’re developing inside the monkeyslegion-components mono-repo, the namespace is already autoloaded.)

🚀 Quick-start
-------------

[](#-quick-start)

```
use MonkeysLegion\Events\{EventDispatcher, ListenerProvider};

// (1) A dumb event DTO
final class RequestEvent
{
    public function __construct(
        public readonly \Psr\Http\Message\ServerRequestInterface $request
    ) {}
}

// (2) Register listeners
$provider = new ListenerProvider();
$provider->add(
    RequestEvent::class,
    fn (RequestEvent $e) => $logger->info(
        $e->request->getMethod().' '.$e->request->getUri()
    ),
    priority: 50                // higher = earlier
);

// (3) Dispatch somewhere in a middleware / controller
$dispatcher = new EventDispatcher($provider);
$dispatcher->dispatch(new RequestEvent($request));
```

🛠 API cheatsheet
----------------

[](#-api-cheatsheet)

```
$provider = new ListenerProvider();

/* register ------------------------------------------------------------ */
$provider->add(OrderPlaced::class, $listener, priority: 10);
$provider->once(UserCreated::class, $listener);          // removed after 1st call

/* remove / clear ------------------------------------------------------ */
$id = $provider->add(SomeEvent::class, $cb);
$provider->remove($id);
$provider->clear();                                      // tests & hot-reload

/* dispatch ------------------------------------------------------------ */
(new EventDispatcher($provider))->dispatch($event);
```

### The provider respects:

[](#the-provider-respects)

- Priority – higher numeric value runs first (20 before 0 before -10)
- FIFO inside the same priority bucket (registration order)
- Inheritance – listeners registered for FooInterface kick in when FooImpl is dispatched (is\_a() check)
- One-shot listeners via once()

♻️ Integration with the DI container
------------------------------------

[](#️-integration-with-the-di-container)

```
use Psr\EventDispatcher\EventDispatcherInterface;
use MonkeysLegion\Events\{ListenerProvider, EventDispatcher};

return [
    ListenerProvider::class        => fn () => new ListenerProvider(),
    EventDispatcherInterface::class => fn ($c) => new EventDispatcher(
        $c->get(ListenerProvider::class)
    ),

    // register a listener at wiring-time
    App\Listener\AuditLogger::class => function ($c) {
        $cb = [$c->get(Psr\Log\LoggerInterface::class), 'info'];
        $c->get(ListenerProvider::class)
           ->add(App\Events\UserDeleted::class, $cb, 5);
        return new App\Listener\AuditLogger();   // if you need an object
    },
];
```

Now any service can simply type-hint EventDispatcherInterface and call dispatch() – swapping the implementation is one line in the container.

🧑‍💻 Contributing
----------------

[](#‍-contributing)

- Fork &amp; clone
- composer install
- Run the test-suite: composer test
- Send a PR – thanks! ❤️

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance70

Regular maintenance activity

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~124 days

Total

2

Last Release

174d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51e4df19377776baa8eafb605d9e7d2374b855c686f552c20d6856e94e3597c3?d=identicon)[yorchperaza](/maintainers/yorchperaza)

---

Top Contributors

[![yorchperaza](https://avatars.githubusercontent.com/u/2913369?v=4)](https://github.com/yorchperaza "yorchperaza (2 commits)")[![Amanar-Marouane](https://avatars.githubusercontent.com/u/155680356?v=4)](https://github.com/Amanar-Marouane "Amanar-Marouane (1 commits)")

### Embed Badge

![Health badge](/badges/monkeyscloud-monkeyslegion-events/health.svg)

```
[![Health](https://phpackages.com/badges/monkeyscloud-monkeyslegion-events/health.svg)](https://phpackages.com/packages/monkeyscloud-monkeyslegion-events)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[spiral/framework

Spiral, High-Performance PHP/Go Framework

2.0k1.8M57](/packages/spiral-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[typo3/cms-core

TYPO3 CMS Core

3512.3M3.8k](/packages/typo3-cms-core)

PHPackages © 2026

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