PHPackages                             messy-one/mediator - 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. messy-one/mediator

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

messy-one/mediator
==================

Simple event mediator for delegating events.

1.3.0(10y ago)023Apache-2.0PHPPHP &gt;=5.6.0

Since Dec 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/messyOne/Mediator)[ Packagist](https://packagist.org/packages/messy-one/mediator)[ Docs](https://github.com/messyOne/Mediator)[ RSS](/packages/messy-one-mediator/feed)WikiDiscussions master Synced today

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

[![Build Status](https://camo.githubusercontent.com/4fa9e36bb9614d879cdde4e016b213471408082c94904e77f46a22975104d718/68747470733a2f2f7472617669732d63692e6f72672f6d657373794f6e652f4d65646961746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/messyOne/Mediator)

Mediator
========

[](#mediator)

Simple event mediator for PHP. Use it if you need a centralized place to handle your events.

How to use
----------

[](#how-to-use)

### Normal usage

[](#normal-usage)

```
   // create an instance
   $mediator = new Mediator();

   // create an class implementing the EventData interface
   class ConcreteEventData implements EventData
   {
       /** @var string */
       private $foo;

       /**
        * @param string $foo
        */
       public function __construct($foo)
       {
           $this->foo = $foo;
       }

       /**
        * @return string
        */
       public function getFoo()
       {
           return $this->foo;
       }
   }

   // attach an event
   $mediator->attach('unique:event', function ($event, ConcreteEventData $data) {
      // do whatever you have to do with $data->getFoo()
   });

   // somewhere else in the code you can trigger the event and send the data to the callback function
   $mediator->trigger('unique:event', new ConcreteEventData('foo'));

```

### Additional information

[](#additional-information)

Since the events are saved in a static variable you might need to delete them (for instance for unit tests).

```
    Mediator::reset();

```

### TODO

[](#todo)

- Add group listening: listen on "main\_event:\*"

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

9

Last Release

3832d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2357092?v=4)[Daniel Weiss](/maintainers/messyOne)[@messyOne](https://github.com/messyOne)

---

Top Contributors

[![messyOne](https://avatars.githubusercontent.com/u/2357092?v=4)](https://github.com/messyOne "messyOne (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/messy-one-mediator/health.svg)

```
[![Health](https://phpackages.com/badges/messy-one-mediator/health.svg)](https://phpackages.com/packages/messy-one-mediator)
```

###  Alternatives

[mmikkel/cp-field-inspect

Inspect field handles and easily edit field and element source settings

29541.1k14](/packages/mmikkel-cp-field-inspect)[fuwasegu/php-enum-util

The extension library for PHP native enum.

119.5k](/packages/fuwasegu-php-enum-util)

PHPackages © 2026

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