Download the PHP package rasuvaeff/yii3-centrifugo without Composer
On this page you can find all versions of the php package rasuvaeff/yii3-centrifugo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rasuvaeff/yii3-centrifugo
More information about rasuvaeff/yii3-centrifugo
Files in rasuvaeff/yii3-centrifugo
Package yii3-centrifugo
Short Description Centrifugo v6 integration for Yii3: server API client, JWT token issuer, and PSR-15 proxy event handlers
License BSD-3-Clause
Homepage https://github.com/rasuvaeff/yii3-centrifugo
Informations about the package yii3-centrifugo
rasuvaeff/yii3-centrifugo
Centrifugo v6 integration for Yii3: full HTTP server API client, JWT connection/subscription token issuers, and PSR-15 proxy event handlers (connect, subscribe, publish, refresh, sub_refresh, rpc).
Using an AI coding assistant? llms.txt has a compact API reference you can paste into context.
Requirements
- PHP 8.3–8.5
- Centrifugo v6
- A PSR-18 HTTP client (e.g.
guzzlehttp/guzzle,symfony/http-client) - A PSR-17 factory (e.g.
nyholm/psr7,guzzlehttp/psr7)
Installation
Then configure in config/params.php:
Usage
Server API Client
CentrifugoClient provides all Centrifugo v6 OSS HTTP API methods. It requires a PSR-18 client and PSR-17 factories to be bound in the DI container.
| Method | Description |
|---|---|
publish(channel, data) |
Publish to one channel |
broadcast(channels, data) |
Publish to many channels |
subscribe(user, channel) |
Subscribe user server-side |
unsubscribe(user, channel) |
Unsubscribe user server-side |
disconnect(user, client?, whitelist?) |
Disconnect user |
refresh(user, client?, expireAt?) |
Refresh connection |
presence(channel) |
Detailed presence info |
presenceStats(channel) |
Aggregated presence counts |
history(channel, limit?, reverse?, since?) |
Channel message history |
historyRemove(channel) |
Clear channel history |
channels(pattern?) |
List active channels |
info() |
Cluster node info |
batch(BatchCommand ...) |
Multiple commands in one request |
JWT Token Issuance
Proxy Events
Centrifugo can proxy connection lifecycle events to your backend over HTTP. Configure endpoints in centrifugo.json:
Register routes in your Yii3 app:
Implement the handler interface in your application:
Bind your handler in the DI container:
Available proxy handlers
| Handler interface | Action class | Centrifugo event |
|---|---|---|
ConnectProxyHandler |
ConnectAction |
Client connects |
RefreshProxyHandler |
RefreshAction |
Connection refresh |
SubscribeProxyHandler |
SubscribeAction |
Client subscribes to channel |
PublishProxyHandler |
PublishAction |
Client publishes to channel |
SubRefreshProxyHandler |
SubRefreshAction |
Subscription refresh |
RpcProxyHandler |
RpcAction |
Client RPC call |
Proxy response types
| Type | JSON envelope | Code range |
|---|---|---|
ProxyResult(array $data) |
{"result": {...}} |
— |
ProxyError(int $code, string $message) |
{"error": {"code": N, "message": "..."}} |
400–1999 |
ProxyDisconnect(int $code, string $reason) |
{"disconnect": {"code": N, "reason": "..."}} |
4000–4999 |
Security
- Proxy endpoints must be reachable only from the Centrifugo server (network ACL or shared secret header via
proxy.http_headersconfig). - HMAC secret and API key are injected from params/env, never hard-coded.
CentrifugoApiExceptionis thrown on Centrifugo API errors (non-zeroerrorin response).ProxyErrorandProxyDisconnectvalidate code ranges in constructors — invalid codes throwInvalidArgumentException.
Examples
See examples/ for runnable scripts.
Development
No PHP or Composer on the host — all commands run inside composer:2 Docker container.
License
BSD-3-Clause. See LICENSE.md.
All versions of yii3-centrifugo with dependencies
lcobucci/jwt Version ^5.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0