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

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

webware/webware-event
=====================

Event system for Webware

0.1.0(1mo ago)01↓50%BSD-3-ClausePHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jun 20Pushed 1mo agoCompare

[ Source](https://github.com/webinertia/webware-event)[ Packagist](https://packagist.org/packages/webware/webware-event)[ RSS](/packages/webware-webware-event/feed)WikiDiscussions 0.1.x Synced 2w ago

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

webware/webware-event
=====================

[](#webwarewebware-event)

[![PHP Version](https://camo.githubusercontent.com/66045fdfea301acd9f0eda4131d6f3ebb65f32c028844d1c453a4605d05357f9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d7e382e342532302537432537432532307e382e352d626c7565)](https://www.php.net/)[![PHPStan](https://camo.githubusercontent.com/022b70e6631d055205dfebf2aa7e53b3f63e7a3ea04a18e86429f279e29a29f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e)](phpstan.neon.dist)[![License](https://camo.githubusercontent.com/e32287373926ec416e0928698ca4471080dc41437461969806bcfe2df245e480/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d677265656e)](LICENSE)

PSR-14 event system for the Mezzio framework — declarative listener wiring, delegator-based dispatcher injection, and PSR-15 middleware integration.

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

[](#installation)

```
composer require webware/webware-event
```

Quick Start
-----------

[](#quick-start)

### 1. Register the config provider

[](#1-register-the-config-provider)

Merge `Webware\Event\ConfigProvider` into your application config (standard Laminas/Mezzio pattern).

### 2. Register listeners in app config

[](#2-register-listeners-in-app-config)

```
return [
    'listeners' => [
        OrderPlaced::class => [
            ['listener' => UpdateInventory::class, 'priority' => 100],
        ],
    ],
    'listener_providers' => [
        CustomListenerProvider::class,
    ],
];
```

### 3. Dispatch events from your services

[](#3-dispatch-events-from-your-services)

```
use Webware\Event\EventDispatcherAwareInterface;
use Webware\Event\EventDispatcherAwareTrait;

class OrderService implements EventDispatcherAwareInterface
{
    use EventDispatcherAwareTrait;

    public function placeOrder(Order $order): void
    {
        // ...business logic...

        $this->eventDispatcher->dispatch(new Event('order.placed', $this, [
            'order_id' => $order->id,
        ]));
    }
}
```

To inject the dispatcher, wire the `EventDispatcherAwareDelegator` for each service that implements `EventDispatcherAwareInterface`:

```
return [
    'dependencies' => [
        'delegators' => [
            OrderService::class => [
                EventDispatcherAwareDelegator::class,
            ],
        ],
    ],
];
```

### 4. Access the dispatcher in HTTP handlers

[](#4-access-the-dispatcher-in-http-handlers)

```
class OrderHandler implements RequestHandlerInterface
{
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $dispatcher = $request->getAttribute(EventDispatcherInterface::class);
        $dispatcher->dispatch(new Event('handler.invoked', $this));

        // ...
    }
}
```

The `EventDispatcherMiddleware` attaches the dispatcher as a request attribute. You must register it in your middleware pipeline to make the dispatcher available to all downstream Middleware/handlers.

Configuration
-------------

[](#configuration)

### `ConfigProvider` keys

[](#configprovider-keys)

KeyTypeDescription`dependencies``array`Container aliases &amp; factories for the dispatcher, aggregate, and middleware.`listeners``array`Event class → listener specs. Merged with app config.`listener_providers``array`Additional `ListenerProviderInterface` FQCNs to attach to the aggregate.### Listener spec formats

[](#listener-spec-formats)

FormatExampleBehaviorClass-string`SendEmail::class`Lazy-resolved from container via `LazyListener`Array with `priority``['listener' => X::class, 'priority' => 100]`Resolved via `PrioritizedListenerProvider`Callable`fn(Event $e) => ...`Attached directlyAllows an object to carry an event instance. Intended for listeners that need access to the event they're processing.

Middleware
----------

[](#middleware)

`EventDispatcherMiddleware` (PSR-15) injects the event dispatcher into the request as an attribute keyed by `EventDispatcherInterface::class`. Register it in your middleware pipeline to make the dispatcher available to all downstream handlers.

Architecture
------------

[](#architecture)

```
ConfigProvider ──▶ container wiring (aliases, factories, listeners)

                         ┌──────────────────┐
                         │   Container       │
                         └──────┬───────────┘
                                │
              ┌─────────────────┼──────────────────┐
              ▼                 ▼                   ▼
   ListenerProviderAggregate   EventDispatcher   EventDispatcherMiddleware
   (resolves listeners)        (phly)            (PSR-15, injects into request)
              │                 │
              └────────┬────────┘
                       │
                 dispatch(Event)
                       │
              ┌────────┴────────┐
              ▼                 ▼
      prioritized listeners   standard listeners

```

### Key classes

[](#key-classes)

ClassNamespaceRole`Event``Webware\Event`Concrete event with name, target, params, and propagation control`ConfigProvider``Webware\Event`Dependency wiring and default config`Configuration``Webware\Event\Container`Typed, validated config extraction from the container`ListenerProviderAggregateFactory``Webware\Event\Container`Builds the listener aggregate from config`EventDispatcherAwareDelegator``Webware\Event\Container`Injects the dispatcher into aware services`EventDispatcherMiddleware``Webware\Event\Middleware`PSR-15 middleware for request-scoped dispatch`EventAwareInterface` / `EventAwareTrait``Webware\Event`Pattern for event-carrying objects`EventDispatcherAwareInterface` / `EventDispatcherAwareTrait``Webware\Event`Pattern for event-dispatching servicesDevelopment
-----------

[](#development)

```
composer check-all    # Run coding standards, static analysis, and tests
composer cs-fix       # Auto-fix coding standard violations
composer sa           # PHPStan level 10 static analysis
composer test         # PHPUnit test suite
```

License
-------

[](#license)

BSD-3-Clause

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance91

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

Total

2

Last Release

45d ago

PHP version history (2 changes)0.1.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

0.1.x-devPHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d6eed33e61a99f1147789696252f4523130b5035a19eb07e034a7407fd44548?d=identicon)[tyrsson](/maintainers/tyrsson)

---

Top Contributors

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

---

Tags

eventpsr-14dispatcherwebware

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpactor/phpactor

PHP refactoring and intellisense tool for text editors

1.9k17.9k1](/packages/phpactor-phpactor)[contributte/event-dispatcher

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

292.5M20](/packages/contributte-event-dispatcher)

PHPackages © 2026

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