PHPackages                             milind/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. milind/php-pubsub

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

milind/php-pubsub
=================

An adapter based PubSub package for PHP

0346PHP

Since Jul 18Pushed 5y agoCompare

[ Source](https://github.com/little-isaac/php-pubsub)[ Packagist](https://packagist.org/packages/milind/php-pubsub)[ RSS](/packages/milind-php-pubsub/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

php-pubsub
==========

[](#php-pubsub)

A PHP abstraction for the pub-sub pattern

[![Author](https://camo.githubusercontent.com/89d1829c61afc8a92333fe0e830ad71714d9fa0cb84cea315ba6162304ff688b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d696c696e642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/milind)[![Build Status](https://camo.githubusercontent.com/6d56b6342097c369a47212af0608c6965adcc12ec241da9f34cd8a4128877e3c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d696c696e642f7068702d7075627375622f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/milind/php-pubsub)[![StyleCI](https://camo.githubusercontent.com/ece7c2ae76a794cf8458a6bb89ef2a88b1e34742f8bfa2e2833c1a4e3e236ebb/68747470733a2f2f7374796c6563692e696f2f7265706f732f36373235313738382f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/67251788)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/92aa685c2830d9055b1db06ddccda28c759e833771a568ada2c76cb2c3e99fff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696c696e642f7068702d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/milind/php-pubsub)[![Total Downloads](https://camo.githubusercontent.com/ff2447747bc6ea9982a9c7d53449c353cca99a429034438493c0ac57083d20f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696c696e642f7068702d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/milind/php-pubsub)

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

[](#installation)

```
composer require milind/php-pubsub
```

Adapters
--------

[](#adapters)

- Local (bundled)
- /dev/null (bundled)
- Redis -
- Kafka -
- Google Cloud -
- HTTP -

Integrations
------------

[](#integrations)

Want to get started quickly? Check out some of these integrations:

- Laravel -

Usage
-----

[](#usage)

```
$adapter = new \milind\PubSub\Adapters\LocalPubSubAdapter();

// consume messages
$adapter->subscribe('my_channel', function ($message) {
    var_dump($message);
});

// publish messages
$adapter->publish('my_channel', 'Hello World!');

// publish multiple messages
$messages = [
    'message 1',
    'message 2',
];
$adapter->publishBatch('my_channel', $messages);
```

Writing an Adapter
------------------

[](#writing-an-adapter)

You can easily write your own custom adapter by implementing the [PubSubAdapterInterface](src/PubSubAdapterInterface.php) interface.

Your adapter must implement the following methods:

```
/**
 * Subscribe a handler to a channel.
 *
 * @param string $channel
 * @param callable $handler
 */
public function subscribe($channel, callable $handler);

/**
 * Publish a message to a channel.
 *
 * @param string $channel
 * @param mixed $message
 */
public function publish($channel, $message);

/**
 * Publish multiple messages to a channel.
 *
 * @param string $channel
 * @param array $messages
 */
public function publishBatch($channel, array $messages);
```

Examples
--------

[](#examples)

The library comes with [examples](examples) for all adapters and a [Dockerfile](Dockerfile) for running the example scripts.

Run `make up`.

You will start at a `bash` prompt in the `/opt/php-pubsub` directory.

If you need another shell to publish a message to a blocking consumer, you can run `docker-compose run php-pubsub /bin/bash`

To run the examples:

```
$ php examples/LocalExample.php
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd0035e6fda13036e33240c5018bba0914101219b774998cebb073c4a7ef2abe?d=identicon)[little-isaac](/maintainers/little-isaac)

---

Top Contributors

[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (18 commits)")

### Embed Badge

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

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

###  Alternatives

[teamones/etcd-discovery

Teamones框架Etcd服务注册和发现组件

107.8k1](/packages/teamones-etcd-discovery)

PHPackages © 2026

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