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

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

yiiboot/event-dispatcher
========================

yii event dispatcher

v1.0.0(3y ago)02[4 PRs](https://github.com/yiiboot/event-dispatcher/pulls)Apache-2.0PHPPHP ^8.1

Since Nov 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yiiboot/event-dispatcher)[ Packagist](https://packagist.org/packages/yiiboot/event-dispatcher)[ Docs](https://github.com/yiiboot)[ GitHub Sponsors](https://github.com/sponsors/yiiboot)[ OpenCollective](https://opencollective.com/yiiboot)[ RSS](/packages/yiiboot-event-dispatcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (6)Used By (0)

 [ ![](https://avatars.githubusercontent.com/u/118281946?s=600&u=b16475d97095b69a8f500ec2f29b8d05c3d02b3a&v=4) ](https://github.com/yiiboot)

Yii Boot Event Dispatcher
=========================

[](#yii-boot-event-dispatcher)

An way to define an event listener with the AsEventListener PHP attribute. This allows to configure the listener inside its class, without having to add any configuration in external files

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

[](#requirements)

- PHP 8.1 or higher.

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

[](#installation)

The package could be installed with composer:

```
composer require yiiboot/event-dispatcher
```

General usage
-------------

[](#general-usage)

the `config/params.php`

```
return [
    // ...
    'yiiboot/attributed' => [
        'paths' => [
            // ...
            dirname(__DIR__) . '/src/EventListener',
        ]
    ]
];
```

the `src/EventListener/MyMultiListener.php`

```
namespace App\EventListener;

use Yiiboot\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(event: CustomEvent::class, method: 'onCustomEvent')]
#[AsEventListener(event: FooEvent::class, priority: 42)]
#[AsEventListener(method: 'onBarEvent', group: ['console', 'web'], env: 'prod')]
final class MyMultiListener
{
    public function onCustomEvent(CustomEvent $event): void
    {
        // ...
    }

    public function onFooEvent(FooEvent $event): void
    {
        // ...
    }

    public function onBarEvent(BarEvent $event): void
    {
        // ...
    }

    #[AsEventListener]
    public function onMethodEvent(BarEvent $event): void
    {
        // ...
    }
}
```

Testing
-------

[](#testing)

### Unit testing

[](#unit-testing)

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```
./vendor/bin/phpunit
```

### Mutation testing

[](#mutation-testing)

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with [Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:

```
./vendor/bin/roave-infection-static-analysis-plugin
```

### Static analysis

[](#static-analysis)

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```
./vendor/bin/psalm
```

### Code style

[](#code-style)

Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or use either newest or any specific version of PHP:

```
./vendor/bin/rector
```

### Dependencies

[](#dependencies)

Use [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker) to detect transitive [Composer](https://getcomposer.org/) dependencies.

License
-------

[](#license)

The Yii Boot Event Dispatcher is free software. It is released under the terms of the Apache-2.0 License. Please see [`LICENSE`](./LICENSE.md) for more information.

Maintained by [Yii Boot](https://github.com/yiiboot).

Support the project
-------------------

[](#support-the-project)

[![Open Collective](https://camo.githubusercontent.com/a2b15f8e2268d4e3842e00d41ff7a57cce2ad8bd8d8769c5dc4fa05a546a4f62/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f70656e253230436f6c6c6563746976652d73706f6e736f722d3765616466313f6c6f676f3d6f70656e253230636f6c6c656374697665266c6f676f436f6c6f723d376561646631266c6162656c436f6c6f723d353535353535)](https://opencollective.com/yiiboot)

Follow updates
--------------

[](#follow-updates)

[![Official website](https://camo.githubusercontent.com/ce0c1f0b71b0a3b66dd8170c51392171c5edc688e7570ecada6e19a0b4d02a03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f426f6f742d677265656e2e7376673f7374796c653d666c6174)](https://github.com/yiiboot)

Inspired &amp;&amp; Thanks
--------------------------

[](#inspired--thanks)

- [Yii Software](https://github.com/yiisoft)
- [Symfony](https://github.com/symfony/symfony)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

1260d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

event dispatcheryii3

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm, Rector

Type Coverage Yes

### Embed Badge

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

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

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

Événement is a very simple event dispatching library for PHP

1.3k147.0M318](/packages/evenement-evenement)[phly/phly-event-dispatcher

Experimental event dispatcher for PSR-14

26209.9k4](/packages/phly-phly-event-dispatcher)

PHPackages © 2026

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