PHPackages                             so-php/pubsub - 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. so-php/pubsub

ActiveLibrary

so-php/pubsub
=============

Publish Subscribe pattern via php-amqplib

0.0.1-alpha(11y ago)0202PHPPHP &gt;=5.3.0

Since May 27Pushed 11y ago1 watchersCompare

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

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

pubsub
======

[](#pubsub)

Publish Subscribe Pattern via php-amqplib

Avoiding Technology Lockout
---------------------------

[](#avoiding-technology-lockout)

One of the goals of ths implementation is to prevent locking out other technologies like python, ruby and java from publishing and subscribing. This is not a terribly difficult task--it just means we need to use a non-proprietary message queue (php-amqplib + rabbitmq) and a message format that isn't language specific. Hence we choose to use a json serialized data structure rather than a PHP serialized string.

That being said, there are no enforced restrictions on the content of the event params. It is up to developers to keep vigilent and be sure not to stuff anything in event parameters that is PHP or platform specific.

Message Structure
-----------------

[](#message-structure)

As stated above, the message is a plain Json string. The structure is an object with three keys (only) at the top level.

- `name` the event name
- `time` the timestamp of the event in ISO 8601. The time should be in UTC.
- `params` an object to hold event params. No imposed limits other than technical feasibility and reasonablenes. Params should be present even if empty `{}`.

```
{
    "name": "some-event-name",
    "datetime": "2005-08-15T15:52:01+0000",
    "params": {
        "any": true,
        "number": 1.3,
        "of": "foo",
        "keys": {
           "of any nesting level": "but be reasonable"
        }
    }
}

```

Usage
-----

[](#usage)

Using PubSub is pretty straight forward. Words in uppercase are values that need to be supplied/configured.

### Publishing

[](#publishing)

```
// need a channel to work with
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$ch = $conn->channel();

$pubSub = new PubSub($ch, EXCHANGE_NAME);
$pubSub->publish('foo', array('hello'=>'world'));

```

### Publishing

[](#publishing-1)

```
// need a channel to work with
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$ch = $conn->channel();

function doSomethingOnEvent(Event e){
   echo "Received event " . $e->getName() . " which was triggered on " . $e->getDateTime()->format('Y-m-d H:i:s') . " with the following params: " . print_r($e->getParams(),true);
}

$pubSub = new PubSub($ch, EXCHANGE_NAME);
$pubSub->subscribe('foo', 'doSomethingOnEvent');

// then wait for (and handle events)
// either:
$pubSub->wait(); // wraps $ch->wait() internally
// or directly on the channel object
$ch->wait();

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

4374d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/so-php-pubsub/health.svg)

```
[![Health](https://phpackages.com/badges/so-php-pubsub/health.svg)](https://phpackages.com/packages/so-php-pubsub)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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