Download the PHP package phpdot/realtime without Composer
On this page you can find all versions of the php package phpdot/realtime. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package realtime
phpdot/realtime
A real-time WebSocket engine for PHPdot — rooms, channels, presence, and broadcast over plain JSON
frames, with a Socket.IO-style Hub/Socket API and an explicit-targeting broadcast operator. It is
transport-agnostic: it reaches clients only through PHPdot\Contracts\Server\ConnectionSenderInterface,
so it never names a concrete server. A pluggable adapter backs membership and presence — a
Swoole\Table for a single node, or Redis for a multi-node cluster.
Table of Contents
- Requirements
- Installation
- Usage
- Architecture
- Testing
- License
Requirements
| Requirement | Constraint |
|---|---|
| PHP | >= 8.5 |
ext-swoole |
>= 6.2 |
phpdot/contracts |
^0.5 |
psr/container |
^2.0 |
psr/http-message |
^2.0 |
Installation
Usage
realtime carries no DI attributes on purpose — you bind the seam in your application. The Hub reaches
clients through ConnectionSenderInterface (implemented by your server's connection registry), and the
Adapter/Hub must be resolved once at bootstrap, before the server forks workers, because
Swoole\Table is shared memory only when created pre-fork:
The Hub is the io: it owns the fd → Socket map, onConnection, emit, to/except/direct,
room(), and the transport lifecycle (handleOpen / handleMessage / handleClose). Each Socket
exposes the per-connection API (emit, broadcast, join/leave, on, disconnect), and
RoomFacade answers presence queries (members(), count()).
Single node vs cluster
TableAdapter coordinates rooms and presence across the workers of one instance through a Swoole\Table.
For several instances behind a load balancer, bind RedisAdapter instead: every node shares membership
through Redis and relays broadcasts over pub/sub. RedisSubscriber runs the blocking SUBSCRIBE loop on a
dedicated connection, and Maintenance\ClusterMaintenance heartbeats each node and reaps the membership
of dead peers so leaked rooms and presence are reclaimed automatically.
Architecture
Application and transport callbacks drive the Hub, which resolves Sockets and fans events out through
the Adapter. The adapter is the only thing that touches storage — a Swoole\Table (single node) or
Redis (cluster) — and the Hub pushes frames to clients solely through ConnectionSenderInterface, so
the engine never depends on a concrete server.
Testing
License
MIT.
This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.
All versions of realtime with dependencies
php Version >=8.5
phpdot/contracts Version ^0.5
psr/container Version ^2.0
psr/http-message Version ^2.0