PHPackages                             garrettw/noair - 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. garrettw/noair

Abandoned → [crell/tukio](/?search=crell%2Ftukio)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

garrettw/noair
==============

PHP event library following the Mediator behavioral pattern implemented like an Observer

v0.2(8y ago)3431LGPL-2.1PHPPHP &gt;=5.4

Since Nov 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/garrettw/noair)[ Packagist](https://packagist.org/packages/garrettw/noair)[ Docs](https://github.com/garrettw/noair)[ RSS](/packages/garrettw-noair/feed)WikiDiscussions master Synced 1w ago

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

[![Packagist Downloads](https://camo.githubusercontent.com/1a2fc8daa73c2d75380b38f627ff602ee50a3613c69d22a56a0daf88248603ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67617272657474772f6e6f6169722e737667)](https://packagist.org/packages/garrettw/noair) [![Latest Stable Version](https://camo.githubusercontent.com/ada8414f219925b952028d484b86c2bc9c0ca37144da82a93391c0c8d3cc7c80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67617272657474772f6e6f6169722e737667)](https://packagist.org/packages/garrettw/noair) [![License](https://camo.githubusercontent.com/ddb2c7d58dc6fc6dcb4d99f085fe1548e15491f81b902903c4f3b04a765cee2d/68747470733a2f2f706f7365722e707567782e6f72672f67617272657474772f6e6f6169722f6c6963656e73652e737667)](https://packagist.org/packages/garrettw/noair)

[![Build Status](https://camo.githubusercontent.com/6850cc3302fca2a0623d1634b02a60af71648d49553c07a09377ca217e0e9354/68747470733a2f2f7472617669732d63692e6f72672f67617272657474772f6e6f6169722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/garrettw/noair) [![Code Climate](https://camo.githubusercontent.com/7b6a6a35adb73cc471933d9db666f72c518638473b0d76e171a77546c0f99ee7/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f67617272657474772f6e6f6169722f6261646765732f6770612e737667)](https://codeclimate.com/github/garrettw/noair) [![SensioLabsInsight](https://camo.githubusercontent.com/6ca49760271644a8c82ef89576c034b2818cd4943df4ac57c53d4a2a95fc92c9/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f66633062633930342d656637372d346564342d623437342d3863653364623961346363322e737667)](https://insight.sensiolabs.com/projects/fc0bc904-ef77-4ed4-b474-8ce3db9a4cc2) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/98f92ce5252ec1fcec0b17b2c167ee04ea0fea8a3534d41beb3e6498c4347248/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67617272657474772f6e6f6169722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/garrettw/noair/?branch=master)

Noair
=====

[](#noair)

Noair (pronounced "no-air") is a PHP library that provides a central event hub that other things can hook into to handle events that are published into that hub. It implements the Mediator behavioral pattern in an Observer style.

**"Why is it called that?"**

We'll get to that in a minute.

**"Why should I use Noair instead of all the other event libraries out there?"**

Because Noair:

- Uses standard Observer-pattern terminology (publish/subscribe)
- Can optionally hang onto published events for which there is no subscriber until such time as a handler subscribes to it
- Supports timer events in addition to normal published events
- Allows handlers to subscribe to any and all events if they want
- Encapsulates event information in an object that gets passed to handlers
- Event objects can hold custom data set by the publisher for handlers to use
- Event objects allow handlers to access the objects that published them
- Event objects allow handlers to access previous handler output (for daisy-chaining)
- Event objects can prevent further daisy-chaining by calling setCancelled()
- Handlers can be simple anonymous functions or contained in observer objects; anything callable
- Observer objects can define handlers explicitly or use on\*() method naming, where \* is the capitalized event name

**"I really need to know the meaning of the name."**

Fine, fine. My project was forked from one called "Podiya", which is Ukrainian for "event". I found out what the word "Podiya" looked like in its original script, and I thought it looked like the letters n-o-A-i-R. [See for yourself.](https://translate.google.com/#en/uk/event)

Core Principles
---------------

[](#core-principles)

- Observers are objects with methods that are called by fired events.
- Those methods are called handlers, or once they are registered, subscribers.
- It is recommended (but optional) that observer objects be used to contain handlers.

Basic usage
-----------

[](#basic-usage)

The idea is that you have multiple event handlers watching a single event hub, waiting for events they can handle.

- First, you'll create child classes of Noair's abstract Observer class that contain handlers:

```
class MyObserver extends \Noair\Observer
{
    public function onThing(\Noair\Event $e)
    {
        return 'do it ' . $e->data;
    }
}
```

- Now, in the main code you're executing, you'll need to create a hub for your events: a Mediator object which serves as a go-between for your handlers and your code that fires/publishes the events.

```
$hub = new \Noair\Mediator(new \Noair\Manager);
```

- Then, you can create objects of your own Observer classes and subscribe them to the hub.

```
$obs = (new MyObserver($hub))->subscribe();
```

- You will then use that Mediator object in your code to publish events that the Observer classes may handle.

```
$hub->publish(new \Noair\Event('thing', 'now'));

// Now if you're an object-oriented fiend like me, you'll probably be calling that
// from within a method, like so:
// $this->mediator->publish(new \Noair\Event('thing', 'now', $this));

// Anyway, either of those will return: 'do it now'
```

Advanced usage
--------------

[](#advanced-usage)

The only "advanced" thing you can do is set up handlers with custom method names, custom priorities, or forceability (this means that the handler will be run even if another handler higher up the chain tries to cancel the rest of the chain). You do this by defining (actually, overriding) the `subscribe()` method as follows:

```
class OtherObserver extends \Noair\Observer
{
    public function subscribe() {
        $this->handlers = [
            'doWeirdThings' => [ // an event name that this class handles
                [$this, 'doWeirdThingsAlways'], // the callable that the event fires
                \Noair\Mediator::PRIORITY_HIGHEST, // how important this handler is
                true, // this is the forceability setting
            ],
        ];

        return parent::subscribe();
    }

    // This is just a normal handler
    public function onThing(\Noair\Event $e)
    {
        return 'do it ' . $e->data;
    }

    // Wait, this function doesn't start with "on"! How can it work?
    // See subscribe() above.
    public function doWeirdThingsAlways(\Noair\Event $e)
    {
        return 'do ' . $e->data . ' ' . rand() . ' times';
    }
}

$hub = new \Noair\Mediator();
$obs = (new OtherObserver($hub))->subscribe();

$hub->publish(new \Noair\Event('doWeirdThings', 'stuff'));
```

That might return: `do stuff 5623 times`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.5% 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 ~330 days

Total

4

Last Release

3215d ago

PHP version history (2 changes)v0.1PHP &gt;=5.5.0

v0.2PHP &gt;=5.4

### Community

Maintainers

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

---

Top Contributors

[![garrettw](https://avatars.githubusercontent.com/u/84885?v=4)](https://github.com/garrettw "garrettw (108 commits)")[![DavidRockin](https://avatars.githubusercontent.com/u/1907079?v=4)](https://github.com/DavidRockin "DavidRockin (41 commits)")

---

Tags

eventlistenerobserverHOOKpublish-subscribemediator

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/garrettw-noair/health.svg)

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

###  Alternatives

[league/event

Event package

1.6k141.6M184](/packages/league-event)[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[jbzoo/event

Library for event-based development

29760.0k5](/packages/jbzoo-event)[pagon/eventemitter

Event Emitter for PHP

2919.3k3](/packages/pagon-eventemitter)[supervisorphp/event

Listen to Supervisor events in PHP

1442.4k](/packages/supervisorphp-event)

PHPackages © 2026

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