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

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

spiffy/spiffy-event
===================

Spiffy\\Event is a light-weight, HHVM compatible, and dependency free event library.

1.0.1(11y ago)121.3k12BSD-3-ClausePHPPHP &gt;=5.4

Since May 8Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (3)Used By (2)

Spiffy\\Event
=============

[](#spiffyevent)

[![Build Status](https://camo.githubusercontent.com/2aa80e9c2b690ecf7dddfcedb97ea59f189b32089ace56f8e169c021c314a663/68747470733a2f2f7472617669732d63692e6f72672f7370696666796a722f7370696666792d6576656e742e737667)](https://travis-ci.org/spiffyjr/spiffy-event)[![Code Coverage](https://camo.githubusercontent.com/0bb22b07502fc1e627fcc56db45706df5306aac8be786d1a579586f67d466bd2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696666796a722f7370696666792d6576656e742f6261646765732f636f7665726167652e706e673f733d32373164346335656538363166343039666331313033373965396265653034663333336361646561)](https://scrutinizer-ci.com/g/spiffyjr/spiffy-event/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9d87643f838dccb4e05e0960dc46de67e67a6b9501e866354ae166464350e7f3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696666796a722f7370696666792d6576656e742f6261646765732f7175616c6974792d73636f72652e706e673f733d32373930363266626562373063653438303536393930656230356438383664623439643133633364)](https://scrutinizer-ci.com/g/spiffyjr/spiffy-event/)

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

[](#installation)

Spiffy\\Event can be installed using composer which will setup any autoloading for you.

`composer require spiffy/spiffy-event`

Additionally, you can download or clone the repository and setup your own autoloading.

Create an event
---------------

[](#create-an-event)

```
use Spiffy\Event\Event;

// Create an event that fires on 'foo'
$event = new Event('foo');

// Creates an event with a target
$event = new Event('foo', 'target');
$event->getTarget(); // 'target'

// Event can have parameters too
$event = new Event('foo', 'target', ['foo' => 'bar']);
$event->getParams()['foo']; // 'bar'
```

Listening to events
-------------------

[](#listening-to-events)

```
use Spiffy\Event\EventManager;

$em = new EventManager();

// Listen with a priority of 1
$em->on('foo', function() { echo 'a'; }, 1);

// Listen with a higher priority
$em->on('foo', function() { echo 'b'; }, 10);

// Event default with priority 0
$em->on('foo', function() { echo 'c'; });
$em->on('foo', function() { echo 'd'; });

// echos 'bacd'
```

Firing events
-------------

[](#firing-events)

```
use Spiffy\Event\Event;
use Spiffy\Event\EventManager;

$em = new EventManager();
$em->on('foo', function() { echo 'fired'; });

// Simplest form of fire requiring just the type
$em->fire('foo'); // fired

// You can also specify the target and params when using the type
$em->fire('foo', 'target', ['foo' => 'bar']);

// You can also provide your own event.
// This is identical to the fire above.
$event = new Event('foo', 'target', ['foo' => 'bar']);
$em->fire($event);
```

Handling responses
------------------

[](#handling-responses)

```
use Spiffy\Event\Event;
use Spiffy\Event\EventManager;

$em = new EventManager();

// Respones are returned as a SplQueue (FIFO).
$em->on('foo', function() { return 'a'; });
$em->on('foo', function() { return 'b'; });

// Outputs 'ab'
foreach ($em->fire('foo') as $response) {
    echo $response;
}
```

Plugins
-------

[](#plugins)

Sometimes you may want to collect several `on()` calls in a single class. Spiffy\\Event provides a `Plugin` interface you can implement and pass to the `plug()` method to prepare several events at a time. The name plugin is used because a collection of events is generally used to plugin additional functionality to an object.

```
use Spiffy\Event\Event;
use Spiffy\Event\Plugin;

class MyPlugin implements Plugin
{
    public function plug(Manager $events)
    {
        $events->on('foo', [$this, 'onFoo']);
    }

    public function onFoo(Event $e)
    {
        echo 'do foo';
    }
}

$em = new EventManager();
$em->attach(new MyPlugin());

// output is 'do foo'
$em->fire('foo');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

4316d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

PHPackages © 2026

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