PHPackages                             yiicod/yii2-listener - 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. yiicod/yii2-listener

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

yiicod/yii2-listener
====================

The simple and powerful event listener for the Yii2 framework

1.0.7(8y ago)1410.8k3MITPHP

Since Jun 6Pushed 8y ago3 watchersCompare

[ Source](https://github.com/yiicod/yii2-listener)[ Packagist](https://packagist.org/packages/yiicod/yii2-listener)[ RSS](/packages/yiicod-yii2-listener/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (9)Used By (0)

Yii Event listener manager
==========================

[](#yii-event-listener-manager)

[![Latest Stable Version](https://camo.githubusercontent.com/e58c4e3eae0e555481665f76c7ce4337768ed3bfa56cca084809a6d52242be74/68747470733a2f2f706f7365722e707567782e6f72672f796969636f642f796969322d6c697374656e65722f762f737461626c65)](https://packagist.org/packages/yiicod/yii2-listener) [![Total Downloads](https://camo.githubusercontent.com/397a7200a5e9bee9a157e344f7ddd8df4b34d1ca92ba26b1bf379fe75fd5bbc6/68747470733a2f2f706f7365722e707567782e6f72672f796969636f642f796969322d6c697374656e65722f646f776e6c6f616473)](https://packagist.org/packages/yiicod/yii2-listener) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/fd700a728d962fa55cea2d0c38cd1058d65f0af7d7de8cc4489b1c376bf4d859/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796969636f642f796969322d6c697374656e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yiicod/yii2-listener/?branch=master)[![Code Climate](https://camo.githubusercontent.com/9b489157961b95f1ed84db0d40e294225912ca559604596db0f4b5097f42b296/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f796969636f642f796969322d6c697374656e65722f6261646765732f6770612e737667)](https://codeclimate.com/github/yiicod/yii2-listener)

Provides listener logic. Command parses chosen paths to find all listener/subscribers (depends on ListenerInterface and SubscriberInterface implementation). Where listener can be used for single event and subscriber can be used for bunch of events.

#### Installation

[](#installation)

Either run

```
php composer.phar require --prefer-dist yiicod/yii2-listener "*"

```

or add

```
"yii2-listener": "*"
```

to your composer.json file

#### Web config

[](#web-config)

```
'bootstrap' => ['listener'],
'components' => [
    'listener' => [
        'class' => 'yiicod\listener\components\Listener'
    ],
]
```

#### Console config

[](#console-config)

```
'controllerMap' => [
    'listener' => [
        'class' => \yiicod\listener\commands\Listener::class
    ],
]
```

Run command. This command will warm and prepare all listeners and subscriptions. Run this command each time when you create new Listener or Subscription.

```
listener/parse
```

For trigger event use yii manual:

#### Listener usage

[](#listener-usage)

```
namespace frontend\observers\listeners;

use yii\db\ActiveRecord;
use yiicod\listener\components\listeners\ListenerAbstract;

class TestListener extends ListenerAbstract
{
   /**
    * Call on event method
    */
   public function handle($event)
   {
       // TODO: Implement handle() method.
   }

   /**
    * Return event name for emit
    * @return string
    */
   public static function event(): string
   {
       return ActiveRecord::class . '@' . ActiveRecord::EVENT_AFTER_FIND;
   }
}
```

#### Usage subscriber

[](#usage-subscriber)

```
namespace frontend\observers\subscribers;

use yii\db\ActiveRecord;
use yiicod\listener\components\listeners\SubscriberAbstract;

class TestSubscriber extends SubscriberAbstract
{
   /**
    * @return array
    * [
    *      'event_class@event1' => 'on'
    *      'event_class@event2' => 'on'
    * ]
    */
   public static function subscribe(): array
   {
       return [
           ActiveRecord::class . '@' . ActiveRecord::EVENT_BEFORE_INSERT => 'on',
           ActiveRecord::class . '@' . ActiveRecord::EVENT_AFTER_INSERT => 'on'
       ];
   }

   /**
    * Call on event method
    */
   public function on($event)
   {
       // Handle
   }
}
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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 ~148 days

Recently: every ~212 days

Total

8

Last Release

3008d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7934283ca98b7f31bb5bf13119a8495cad80ac9097125a48792f47caddb588b9?d=identicon)[lexxorlov](/maintainers/lexxorlov)

---

Top Contributors

[![lexxorlov](https://avatars.githubusercontent.com/u/7910574?v=4)](https://github.com/lexxorlov "lexxorlov (16 commits)")[![dimitu](https://avatars.githubusercontent.com/u/8487915?v=4)](https://github.com/dimitu "dimitu (1 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yiicod-yii2-listener/health.svg)

```
[![Health](https://phpackages.com/badges/yiicod-yii2-listener/health.svg)](https://phpackages.com/packages/yiicod-yii2-listener)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.3k](/packages/friendsofphp-php-cs-fixer)[symfony/stimulus-bundle

Integration with your Symfony app &amp; Stimulus!

17417.5M295](/packages/symfony-stimulus-bundle)[illuminate/session

The Illuminate Session package.

9939.3M850](/packages/illuminate-session)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

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