PHPackages                             mehr-it/system-broadcast - 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. [Caching](/categories/caching)
4. /
5. mehr-it/system-broadcast

ActiveLibrary[Caching](/categories/caching)

mehr-it/system-broadcast
========================

Broadcast library for internal communication in distributed systems using Redis

1.0.0(6y ago)06MITPHPPHP ^7.0

Since May 20Pushed 6y agoCompare

[ Source](https://github.com/mehr-it/system-broadcast)[ Packagist](https://packagist.org/packages/mehr-it/system-broadcast)[ RSS](/packages/mehr-it-system-broadcast/feed)WikiDiscussions master Synced today

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

System broadcast
================

[](#system-broadcast)

This package implements internal broadcasting for distributed systems using Redis.

Internally Redis `publish`/`subscribe` commands are used. This library offers an easy interface for publishing and receiving messages and provides a mechanism to check whether some messages were missed while the broadcast channel was not subscribed.

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

[](#basic-usage)

Implementing a publisher is very easy:

```
$broadcast = new SystemBroadcast(['host' => '127.0.0.1'], 'my-channel');
$broadcast->publish('my-message');

```

The corresponding listener would look like this:

```
$broadcast = new SystemBroadcast(['host' => '127.0.0.1'], 'my-channel');
$broadcast->handler('my-message', function() {
	// do something
})
$broadcast->listen();

```

### Passing data together with messages

[](#passing-data-together-with-messages)

You may pass any JSON serializable data together with messages:

```
$broadcast->publish('my-message', $data);

```

The handler will receive the data as first parameter:

```
$broadcast->handler('my-message', function($data) {
	// do something
})

```

Missed messages
---------------

[](#missed-messages)

While listening for broadcasts, listeners receive all messages. However if your listener process is not running for whatever reason, all messages published meanwhile are irrevocably lost for this client.

Even if you cannot recover missed messages, you can check if you missed any published messages on the broadcast channel. Your handler can receive a sequence value and save it to a file:

```
$broadcast->handler('my-message', function($data, $broadcast) {
	$seq = $broadcast->sequence();

	/* ... save it to file */
})

```

Before you start listening, you can register an `onListen`-callback, which receives the current sequence value right after listening is established. If this value does not equal the last value stored by the handler, you missed some messages:

```
$broadcast->onListen(function($sequence) {

	$expected = /* ... load last sequence value from file */

	if ($sequence != $expected) {
		/* handle inconsitency */
	}

});

```

Signing messages
----------------

[](#signing-messages)

Since messages can be very critical, you may sign messages. To do so, use the `setSignKey`method to set the same secret for publishers and listeners.

See class documentation for additional signing parameters.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

2549d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44973729?v=4)[mehr.IT GmbH](/maintainers/mehr-it)[@mehr-it](https://github.com/mehr-it)

---

Tags

redissysteminternalBroadcastdistributed systemsdistributed system

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mehr-it-system-broadcast/health.svg)

```
[![Health](https://phpackages.com/badges/mehr-it-system-broadcast/health.svg)](https://phpackages.com/packages/mehr-it-system-broadcast)
```

###  Alternatives

[predis/predis-async

Asynchronous version of Predis

366348.4k](/packages/predis-predis-async)[rhubarbgroup/redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

51795.3k1](/packages/rhubarbgroup-redis-cache)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[predis/service-provider

Predis service provider for the Silex microframework

68546.6k1](/packages/predis-service-provider)[jamescauwelier/psredis

Sentinel client for the popular php redis client

77392.9k5](/packages/jamescauwelier-psredis)[cache/predis-adapter

A PSR-6 cache implementation using Redis (Predis). This implementation supports tags

272.6M13](/packages/cache-predis-adapter)

PHPackages © 2026

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