PHPackages                             acairns/radiate - 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. acairns/radiate

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

acairns/radiate
===============

Radiate event emitter

0.1.2(9y ago)157.5k2MITPHPPHP &gt;=7.0.0

Since Sep 26Pushed 8y agoCompare

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

READMEChangelogDependencies (2)Versions (4)Used By (0)

Radiate
=======

[](#radiate)

[![Build Status](https://camo.githubusercontent.com/8d3a49845ab7092f469e03c2e61ab21b784488ae379def96512cd91148567b3c/68747470733a2f2f7472617669732d63692e6f72672f61636169726e732f726164696174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/acairns/radiate)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7f776352f0549c000aac3a2547b8358a93a3fb7d04c60d049f47df207a2db3ac/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61636169726e732f726164696174652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/acairns/radiate/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/c2c1b7727fb9d815beb48207c1999163bd79f8eaeb02e28057b1069ddaa77d64/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61636169726e732f726164696174652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/acairns/radiate/?branch=master)

---

Introduction
------------

[](#introduction)

Radiate is a package for managing Events.

### Basic Usage

[](#basic-usage)

Simply create an instance of the `Emitter` and emit events!

```
$emitter new Emitter($middleware);
$emitter->emit(new ExampleEvent);

```

### Creating the Emitter

[](#creating-the-emitter)

Radiate requires a pipeline of middleware when being created. The main middleware required to invoke listeners is an instance of the `InvokeListenerMiddleware` class.

```
use Cairns\Radiate\Emitter;
use Cairns\Radiate\Inflector\HandleMethodInflector;
use Cairns\Radiate\Middleware\InvokeListenerMiddleware;

$invoker = new InvokeListenerMiddleware(
    $registry,
    $locator,
    $inflector
);

$emitter = new Cairns\Radiate\Emitter([
    $invoker
]);

```

In order to invoke a Listener, the middleware needs to know the available Listeners (`$registry`), how to create an instance of the subscribed Listeners (`$locator`) and how to determine which method should be invoked (`$inflector`).

### Registrys

[](#registrys)

A Registry is a simple class responsible of keeping track all of the subscribed Listeners.

### Locators

[](#locators)

The responsibility of the locator is to take a Fully Qualified Class Name for a Listener and to return an instance. If you are using a Dependency Injection container, then this is where you want to resolve the concrete instance.

### Inflectors

[](#inflectors)

The job of the inflector is to determine which method should be called on a particular Listener given a specific Event. Several Inflectors are provided for common setups.

#### HandleMethodInflector

[](#handlemethodinflector)

The `HandleMethodInflector` ensures the `handle()` method is returned. A Listener could look like this:

```
final class DisableTransporters
{
    public function handle(WarpDriveEngaged $event)
    {
        // Do Something
    }
}

```

#### TypehintMethodInflector

[](#typehintmethodinflector)

The `TypehintMethodInflector` ensures any method dependent on the type of event is returned. A Listener could look like this:

```
final class DisableTransporters
{
    public function whenWarpDriveEngaged(WarpDriveEngaged $event)
    {
        // Do Something
    }

    public function whenShieldsWereRaised(ShieldsWereRaised $event)
    {
        // Do Something
    }
}

```

When using the `TypehintMethodInflector`, you can define multiple public methods so that the same Listener can respond to different events.

Simple Example
--------------

[](#simple-example)

```
final class WarpDriveEngaged
{
    private $speed;

    public function __construct($speed)
    {
        $this->speed = $speed;
    }

    public function getSpeed()
    {
        return $this->speed;
    }
}

final class DisableTransporters
{
    public function whenWarpDriveIsEngaged(WarpDriveEngaged $event)
    {
        // safety first!
    }
}

$registry = new \Cairns\Radiate\Registry\TypehintedClassRegistry;
$registry->register(DisableTransporters::class);

$locator = new Cairns\Radiate\Locator\InMemoryListenerLocator;
$locator->add(new DisableTransporters);

$invoker = new \Cairns\Radiate\Middleware\InvokeListenerMiddleware(
    $registry,
    $locator,
    new Cairns\Radiate\Inflector\TypehintMethodInflector
);

$emitter = new Cairns\Radiate\Emitter([
    $invoker
]);

$emitter->emit(new WarpDriveEngaged(9));
```

Inspiration
-----------

[](#inspiration)

This library is inspired by:

- [SimpleBus/MessageBus](https://github.com/SimpleBus/MessageBus)
- [thephpleague/tactician](https://github.com/thephpleague/tactician)
- [thephpleague/event](https://github.com/thephpleague/event)

Contributing
------------

[](#contributing)

Even though this is just an experiment for now, I'm totally open to ideas. Shoot over a PR!

If you decide to help out, here are some helpful things to check:

### Running tests

[](#running-tests)

```
$ ./vendor/bin/phpunit

```

### Code Sniffer

[](#code-sniffer)

```
$ ./vendor/bin/phpcs --standard=PSR2 ./src/

```

Todo
----

[](#todo)

- Bump to &gt;=PHP7, update codebase (return types, typehint, etc.)
- Extract examples into example directory
- Make registry serialisable, and constructable from a serialised registry

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3509d ago

### Community

Maintainers

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

---

Top Contributors

[![acairns](https://avatars.githubusercontent.com/u/705212?v=4)](https://github.com/acairns "acairns (77 commits)")

---

Tags

emittereventseventlisteneremitter

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/acairns-radiate/health.svg)

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

###  Alternatives

[league/event

Event package

1.6k141.6M184](/packages/league-event)[contributte/event-dispatcher

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

292.4M19](/packages/contributte-event-dispatcher)[jbzoo/event

Library for event-based development

29760.0k5](/packages/jbzoo-event)[supervisorphp/event

Listen to Supervisor events in PHP

1442.4k](/packages/supervisorphp-event)

PHPackages © 2026

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