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

ActiveLibrary

studio24/pubsub
===============

Simple implementation of the PubSub design pattern in PHP

v1.0.2(9y ago)0221MITPHPPHP &gt;=5.6.0

Since Mar 28Pushed 9y ago1 watchersCompare

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

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

PubSub
======

[](#pubsub)

Simple implementation of the PubSub design pattern in PHP.

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

[](#installation)

```
composer require studio24/pubsub
```

Usage
-----

[](#usage)

Import at the top of your PHP script via:

```
use Studio24\PubSub\PubSub;
```

### Add a task to run at a certain event (subscribe)

[](#add-a-task-to-run-at-a-certain-event-subscribe)

This will run the passed anonymous function when the event 'myevent' is run.

```
PubSub::subscribe('myevent', function($name){
    // My code goes here
    echo $name;
});
```

#### PubSub::subscribe($event, $callback, $weight)

[](#pubsubsubscribeevent-callback-weight)

Params:

- $event (string) Event name
- $callback (callback) Callback function to run
- $weight (int) Optional, weight to define the order subscribed tasks run, defaults to 10. The lower the number the earlier this callback runs

### Run tasks at a certain event (publish)

[](#run-tasks-at-a-certain-event-publish)

This runs all tasks which are subscribed to the 'myevent' event, passing the argument $name.

```
PubSub::publish('myevent', $name);
```

#### PubSub::publish($event, ...$arguments)

[](#pubsubpublishevent-arguments)

Params:

- $event (string) Event name
- $arguments (mixed) Optional, one or many arguments to pass to the callback function

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [Simon R Jones](https://github.com/simonrjones)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~70 days

Total

3

Last Release

3559d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/70464d5c596a2aa2b4bf2f5253ae463499ad769e3ab4293ffa3f123a24da56d4?d=identicon)[AlanJIsaacson](/maintainers/AlanJIsaacson)

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

---

Top Contributors

[![simonrjones](https://avatars.githubusercontent.com/u/601316?v=4)](https://github.com/simonrjones "simonrjones (6 commits)")[![robertprice](https://avatars.githubusercontent.com/u/1425925?v=4)](https://github.com/robertprice "robertprice (1 commits)")

---

Tags

eventsmessagingpubsubpublish-subscribe

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[nuwber/rabbitevents

The Nuwber RabbitEvents package

120515.8k3](/packages/nuwber-rabbitevents)[chocofamilyme/laravel-pubsub

AMQP wrapper for Laravel to publish and consume messages

1120.0k](/packages/chocofamilyme-laravel-pubsub)[denpa/laravel-zeromq

ZeroMQ driver for Laravel

171.1k](/packages/denpa-laravel-zeromq)

PHPackages © 2026

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