PHPackages                             valeriitropin/socketio-redis-adapter - 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. valeriitropin/socketio-redis-adapter

ActiveLibrary[Caching](/categories/caching)

valeriitropin/socketio-redis-adapter
====================================

1.0.0(8y ago)118MITPHP

Since Dec 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/valeriitropin/php-socketio-redis-adapter)[ Packagist](https://packagist.org/packages/valeriitropin/socketio-redis-adapter)[ RSS](/packages/valeriitropin-socketio-redis-adapter/feed)WikiDiscussions master Synced 2w ago

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

PHP socket.io redis adapter
===========================

[](#php-socketio-redis-adapter)

Partial port of socket.io redis adapter, async, allows to get clients/rooms and to manage them. The main goal of this project is possibility to communicate between php and socket.io applications. Built on top of [ReactPHP](https://reactphp.org/) components.

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

[](#installation)

```
composer require valeriitropin/socketio-redis-adapter

```

How to use
----------

[](#how-to-use)

```
use React\EventLoop\Factory as ReactFactory;
use ValeriiTropin\Socketio\RedisAdapter;
use Clue\React\Block;
use React\Promise;

$loop = ReactFactory::create();
$client = new RedisAdapter($loop);

$promise = $client->allRooms()->then(function ($rooms) use ($client) {
    $promises = [];
    foreach ($rooms as $room) {
        $promises[] = $client->clients([$room])->then(function ($clients) use ($room) {
            foreach ($clients as $client) {
                echo $room . ' ' . $client . "\n";
            }
        });
    }
    return Promise\all($promises);
})->otherwise(function ($error) {
    echo ($error->getMessage()) . "\n";
});

Block\await($promise, $loop);
```

API
---

[](#api)

### RedisAdapter

[](#redisadapter)

#### \_\_construct(React\\EventLoop\\LoopInterface $loop, $options = \[\])

[](#__constructreacteventlooploopinterface-loop-options--)

##### $options:

[](#options)

- `prefix`: pub/sub events prefix (`socket.io`)
- `requestsTimeout`: timeout in milliseconds, float (`5`)
- `namespace`: socket.io namespace (`/`)
- `pubClient`: pub client
- `subClient`: pub client
- `customHook`: callable
- `uri`: Redis connection string, see [docs](https://github.com/clue/php-redis-react/blob/master/README.md#createclient) (`localhost`)

### clients($rooms = \[\]): React\\Promise\\Promise

[](#clientsrooms---reactpromisepromise)

Returns the list of client IDs connected to `rooms` across all nodes.

```
$adapter->clients($rooms)
    ->then(function ($clients) {
        var_dump($clients);
    })
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### clientRooms($id): React\\Promise\\Promise

[](#clientroomsid-reactpromisepromise)

Returns the list of rooms the client with the given ID has joined (even on another node).

```
$adapter->clients($id)
    ->then(function ($rooms) {
        var_dump($rooms);
    })
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### allRooms(): React\\Promise\\Promise

[](#allrooms-reactpromisepromise)

Returns the list of all rooms from all nodes.

```
$adapter->allRooms()
    ->then(function ($allRooms) {
        var_dump($allRooms);
    })
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### remoteJoin($id, $room): React\\Promise\\Promise

[](#remotejoinid-room-reactpromisepromise)

```
$adapter->remoteJoin($id, $room)
    ->then(function () {})
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### remoteLeave($id, $room): React\\Promise\\Promise

[](#remoteleaveid-room-reactpromisepromise)

```
$adapter->remoteLeave($id, $room)
    ->then(function () {})
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### remoteDisconnect($id, $close): React\\Promise\\Promise

[](#remotedisconnectid-close-reactpromisepromise)

```
$adapter->remoteDisconnect($id, $close)
    ->then(function () {})
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### customRequest($data): React\\Promise\\Promise

[](#customrequestdata-reactpromisepromise)

Sends a request to every nodes, that will respond through the `customHook` method.

```
$adapter->customRequest($data)
    ->then(function ($replies) {})
    ->otherwise(function ($error) {
        echo ($error->getMessage()) . "\n";
    });
```

### getLoop(): React\\EventLoop\\LoopInterface

[](#getloop-reacteventlooploopinterface)

Returns loop instance.

### getPub(): Clue\\React\\Redis\\StreamingClient

[](#getpub-cluereactredisstreamingclient)

Returns pub client.

### getSub(): Clue\\React\\Redis\\StreamingClient

[](#getsub-cluereactredisstreamingclient)

Returns sub client.

### unsubscribeFromRequestChannel(): React\\Promise\\Promise

[](#unsubscribefromrequestchannel-reactpromisepromise)

Unsubscribes the adapter instance from request channel.

Links
-----

[](#links)

- [Socket.io](https://github.com/socketio/socket.io)
- [Socket.io Redis adapter](https://github.com/socketio/socket.io-redis)
- [ReactPHP promises](https://reactphp.org/promise/)
- [ReactPHP Redis](https://github.com/clue/php-redis-react)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

3115d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5775964?v=4)[Valerii Tropin](/maintainers/valeriitropin)[@valeriitropin](https://github.com/valeriitropin)

---

Top Contributors

[![valeriitropin](https://avatars.githubusercontent.com/u/5775964?v=4)](https://github.com/valeriitropin "valeriitropin (1 commits)")

---

Tags

redisadapterSocket.io

### Embed Badge

![Health badge](/badges/valeriitropin-socketio-redis-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/valeriitropin-socketio-redis-adapter/health.svg)](https://phpackages.com/packages/valeriitropin-socketio-redis-adapter)
```

###  Alternatives

[predis/predis

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

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

A Redis bundle for Symfony

1.0k40.4M72](/packages/snc-redis-bundle)[clue/redis-protocol

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

5214.4M13](/packages/clue-redis-protocol)[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.

23617.0k1](/packages/rtcamp-nginx-helper)[rtckit/react-redlock

Asynchronous distributed locks with Redis and ReactPHP

177.8k1](/packages/rtckit-react-redlock)

PHPackages © 2026

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