PHPackages                             friendsofhyperf/redis-subscriber - 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. friendsofhyperf/redis-subscriber

ActiveLibrary[Caching](/categories/caching)

friendsofhyperf/redis-subscriber
================================

Redis native protocol Subscriber based on Swoole coroutine

v3.1.75(5mo ago)21.7k↑200%1MITPHP

Since May 29Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/friendsofhyperf/redis-subscriber)[ Packagist](https://packagist.org/packages/friendsofhyperf/redis-subscriber)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-redis-subscriber/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (1)

Redis Subscriber
================

[](#redis-subscriber)

[![Latest Stable Version](https://camo.githubusercontent.com/260ac63861a03c031dfec306bf9109cf19e737e3d712010bce88b522e0ef89b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64736f666879706572662f72656469732d73756273637269626572)](https://packagist.org/packages/friendsofhyperf/redis-subscriber)[![Total Downloads](https://camo.githubusercontent.com/c33f5b454012bcda8ec66769ca5fa1378ca4fe636219df242c56c9197010ae19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667269656e64736f666879706572662f72656469732d73756273637269626572)](https://packagist.org/packages/friendsofhyperf/redis-subscriber)[![License](https://camo.githubusercontent.com/ec0fcb4a6aca2c6bf04dfeeeda9b383282e238e48cc13b0e0b14d496275bdecd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f667269656e64736f666879706572662f72656469732d73756273637269626572)](https://github.com/friendsofhyperf/redis-subscriber)

Forked from [mix-php/redis-subscriber](https://github.com/mix-php/redis-subscriber)

A Redis native protocol Subscriber based on Swoole coroutine

A Redis native protocol subscription library based on Swoole coroutine

It connects directly to the Redis server using a Socket, independent of the phpredis extension. This subscriber has the following advantages:

- Smooth modification: Subscriptions can be added or canceled at any time, fulfilling the need for seamless channel switching.
- Safe closure across coroutines: Subscription can be closed at any moment.
- Channel message retrieval: This library's encapsulation style is inspired by the [go-redis](https://github.com/go-redis/redis) library in the Go language, retrieving subscribed messages through a channel.

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

[](#installation)

```
composer require friendsofhyperf/redis-subscriber
```

Subscribing to Channels
-----------------------

[](#subscribing-to-channels)

- Connection or subscription failures will throw an exception

```
$sub = new \FriendsOfHyperf\Redis\Subscriber\Subscriber('127.0.0.1', 6379, '', 5); // Connection failure will throw an exception
$sub->subscribe('foo', 'bar'); // Subscription failure will throw an exception

$chan = $sub->channel();
while (true) {
    $data = $chan->pop();
    if (empty($data)) { // Manual close or abnormal disconnection from Redis will return false
        if (!$sub->closed) {
            // Handle abnormal disconnection from Redis
            var_dump('Redis connection is disconnected abnormally');
        }
        break;
    }
    var_dump($data);
}
```

Receiving subscribed messages:

```
object(FriendsOfHyperf\Redis\Subscriber\Message)#8 (2) {
  ["channel"]=>
  string(2) "foo"
  ["payload"]=>
  string(4) "test"
}
```

All Methods
-----------

[](#all-methods)

MethodDescriptionsubscribe(string ...$channels) : voidAdd subscriptionsunsubscribe(string ...$channels) : voidCancel subscriptionspsubscribe(string ...$channels) : voidAdd pattern subscriptionspunsubscribe(string ...$channels) : voidCancel pattern subscriptionschannel() : Hyperf\\Engine\\ChannelRetrieve the message channelclose() : voidClose the subscriptionLicense
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance71

Regular maintenance activity

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

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

Every ~50 days

Recently: every ~18 days

Total

12

Last Release

171d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8337659?v=4)[Deeka Wong](/maintainers/huangdijia)[@huangdijia](https://github.com/huangdijia)

---

Top Contributors

[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (19 commits)")

---

Tags

redisswoolesubscriber

### Embed Badge

![Health badge](/badges/friendsofhyperf-redis-subscriber/health.svg)

```
[![Health](https://phpackages.com/badges/friendsofhyperf-redis-subscriber/health.svg)](https://phpackages.com/packages/friendsofhyperf-redis-subscriber)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[mix/redis-subscriber

Redis native protocol Subscriber based on Swoole coroutine

151.8M2](/packages/mix-redis-subscriber)[clue/redis-protocol

A streaming Redis protocol (RESP) parser and serializer written in pure PHP.

5211.0M13](/packages/clue-redis-protocol)[swoft/redis

swoft redis component

12168.4k16](/packages/swoft-redis)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23517.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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