PHPackages                             weew/eventer - 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. weew/eventer

ActiveLibrary

weew/eventer
============

Simple event system.

v2.2.2(9y ago)034911MITPHP

Since Aug 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/weew/eventer)[ Packagist](https://packagist.org/packages/weew/eventer)[ RSS](/packages/weew-eventer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (11)Used By (1)

Simple event system
===================

[](#simple-event-system)

[![Build Status](https://camo.githubusercontent.com/c6e2a8a0b21d1b2830c5ebfde45eeee94f5369bda5bd4b5eaa4a06e1f7dd57a8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776565772f6576656e7465722e737667)](https://travis-ci.org/weew/eventer)[![Code Quality](https://camo.githubusercontent.com/c5e06de00b72bdbd8d4a3ea7a0c3d39ea670c513e7aef7e76bc8d03fb6699f17/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776565772f6576656e7465722e737667)](https://scrutinizer-ci.com/g/weew/eventer)[![Test Coverage](https://camo.githubusercontent.com/d5045efe81808634da153acbccddeab52ac270e48b0bf65f84e5b9a74846bcb9/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f776565772f6576656e7465722e737667)](https://coveralls.io/github/weew/eventer)[![Version](https://camo.githubusercontent.com/8af31b1eb1861551439bb6f923618d66056e4d2527ba8141bbc68f7c258ab622/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776565772f6576656e7465722e737667)](https://packagist.org/packages/weew/eventer)[![Licence](https://camo.githubusercontent.com/28b4d235e148c65dd3b1713fc654b27ba0f32c23619eafeaa42cbf5d77dc9ac9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776565772f6576656e7465722e737667)](https://packagist.org/packages/weew/eventer)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Simple subscription](#simple-subscription)
    - [Attaching data to an event](#attaching-data-to-an-event)
    - [Creating custom events](#creating-custom-events)
    - [Unsubscribing from events](#unsubscribing-from-events)
    - [Event subscribers](#event-subscribers)
- [Existing container integrations](#existing-container-integrations)

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

[](#installation)

`composer install weew/eventer`

Usage
-----

[](#usage)

This event system allows you to easily subscribe to certain events and get notified as soon as one occurs. The most simple way to subscribe to an event is by using a string as the event name.

### Simple subscription

[](#simple-subscription)

The easiest way to create a subscription is to use callback function.

```
$eventer = new Eventer();
$eventer->subscribe('event.name', function(IEvent $event) {
    echo $event->getName();
    // event.name
});
$eventer->dispatch('event.name');
```

### Attaching data to an event

[](#attaching-data-to-an-event)

Mostly you want to throw an event with particular data attached. The quickest way to achieve this is to use the generic events.

```
$eventer = new Eventer();
$eventer->subscribe('event.name', function(IEvent $event) {
    var_dump($event->getData());
    // ['secret' => 'secret value']
    echo $event->get('secret');
    // secret value
});

$event = new GenericEvent('event.name', ['secret' => 'secret value']);
// or
$event = new GenericEvent('event.name');
$event->set('secret', 'secret value');

$eventer->dispatch($event);
```

### Creating custom events

[](#creating-custom-events)

In more complex applications I would suggest to roll your own events. This makes the code much more easier to understand since you'll never have to guess what the event name might be. It also allows you to extend your events with more complex behaviour.

```
class CustomEvent extends Event {
    public function getSecret() {
        return 'secret value';
    }
}

$eventer = new Eventer();
$eventer->subscribe(CustomEvent::class, function(CustomEvent $event) {
    echo $event->getSecret();
    // secret value
});

$eventer->dispatch(new CustomEvent());
```

### Unsubscribing from events

[](#unsubscribing-from-events)

To unsubscribe from an event you can simply pass the subscription object to the unsubscribe method on the event dispatcher.

```
$eventer = new Eventer();
$subscription = $eventer->subscribe('event.name', 'abstract.value');
$eventer->unsubscribe($subscription);
```

### Event subscribers

[](#event-subscribers)

Using callbacks in your events might not always be an optimal solution. Therefore you can create event subscriber classes that get called whenever an event occurs. The class must have the `handle(IEvent $event)` method, but there is no specific interface that you are forced to implement.

```
class CustomEvent extends Event {
    public function getSecret() {
        return 'secret value';
    }
}

class CustomEventSubscriber {
    public function handle(IEvent $event) {
        /** @var CustomEvent $event */
        echo $event->getSecret();
        // secret value
    }
}

$eventer = new Eventer();
$eventer->subscribe(CustomEvent::class, CustomEventSubscriber::class);
$eventer->dispatch(new CustomEvent());
```

Existing container integrations
-------------------------------

[](#existing-container-integrations)

There is an integration for the [weew/container](https://github.com/weew/container). See [eventer-container-aware](https://github.com/weew/eventer-container-aware).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~37 days

Recently: every ~49 days

Total

10

Last Release

3585d ago

Major Versions

v0.0.4 → v1.0.02015-11-16

v1.0.0 → v2.0.02016-01-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/10b2b854b5829dd13a15967c000ed2119b5faef67aca24d94c653c8ac550d85e?d=identicon)[weew](/maintainers/weew)

---

Top Contributors

[![maximkott](https://avatars.githubusercontent.com/u/2686062?v=4)](https://github.com/maximkott "maximkott (1 commits)")[![mikeSimonson](https://avatars.githubusercontent.com/u/907613?v=4)](https://github.com/mikeSimonson "mikeSimonson (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/weew-eventer/health.svg)

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

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)

PHPackages © 2026

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