PHPackages                             uzdevid/yii-runner-centrifugo - 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. [Framework](/categories/framework)
4. /
5. uzdevid/yii-runner-centrifugo

ActiveLibrary[Framework](/categories/framework)

uzdevid/yii-runner-centrifugo
=============================

Centrifugo &amp; RoadRunner based Yii runner

24[3 PRs](https://github.com/uzdevid/yii-runner-centrifugo/pulls)PHPCI failing

Since Jun 21Pushed 4mo agoCompare

[ Source](https://github.com/uzdevid/yii-runner-centrifugo)[ Packagist](https://packagist.org/packages/uzdevid/yii-runner-centrifugo)[ RSS](/packages/uzdevid-yii-runner-centrifugo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

 [ ![Yii](https://private-user-images.githubusercontent.com/167644693/420289040-e29daa5f-ac8f-47aa-b927-40400a6b5626.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0OTU1NDEsIm5iZiI6MTc3NTQ5NTI0MSwicGF0aCI6Ii8xNjc2NDQ2OTMvNDIwMjg5MDQwLWUyOWRhYTVmLWFjOGYtNDdhYS1iOTI3LTQwNDAwYTZiNTYyNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQxNzA3MjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jZDE2YjM5NGIxMjVkNTM3YmRjYTkxZGU1NzY0OTlkZGRjNTllZGU0MTdlZDY4YWY0ZmY5MmFhM2VmNjAxODFkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Y629CPgPNtbLa35jINopR2MhcKqevDw-hhsa6dUz3Cc) ](https://github.com/uzdevid)

Yii RoadRunner Centrifugo
=========================

[](#yii-roadrunner-centrifugo)

[![Latest Stable Version](https://camo.githubusercontent.com/db3701efcfb9aea8bb4efc33eae0d29d3fd177734d93aed6ac5d164e9a6e68a6/68747470733a2f2f706f7365722e707567782e6f72672f757a64657669642f7969692d72756e6e65722d63656e7472696675676f2f76)](https://packagist.org/packages/yiisoft/yii-runner-centrifugo)[![Total Downloads](https://camo.githubusercontent.com/dbdcbc1b1a6ffebd44a4912b75af67d47b6f72f0f4a2694db891d4fa5e5609e1/68747470733a2f2f706f7365722e707567782e6f72672f757a64657669642f7969692d72756e6e65722d63656e7472696675676f2f646f776e6c6f616473)](https://packagist.org/packages/uzdevid/yii-runner-centrifugo)[![Build status](https://github.com/uzdevid/yii-runner-centrifugo/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/uzdevid/yii-runner-centrifugo/actions/workflows/build.yml?query=branch%3Amaster)[![Code Coverage](https://camo.githubusercontent.com/a964bdcc5eca446491ee86ae137b1f36bbfa5e2fa8baf67d36559c496e4afb71/68747470733a2f2f636f6465636f762e696f2f67682f757a64657669642f7969692d72756e6e65722d63656e7472696675676f2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/uzdevid/yii-runner-centrifugo)[![Mutation testing badge](https://camo.githubusercontent.com/1577b11385b80a9e7f619137bcb1315592f4d0dcba7f923bea6d742eae9bc6d5/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246757a64657669642532467969692d72756e6e65722d63656e7472696675676f2532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/uzdevid/yii-runner-centrifugo/master)[![Static analysis](https://github.com/uzdevid/yii-runner-centrifugo/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/uzdevid/yii-runner-centrifugo/actions/workflows/static.yml?query=branch%3Amaster)[![type-coverage](https://camo.githubusercontent.com/d0c470ef08357c41e0c3975e13dbda98ed246bb188f1dbe486cfb693a158b5d8/68747470733a2f2f73686570686572642e6465762f6769746875622f757a64657669642f7969692d72756e6e65722d63656e7472696675676f2f636f7665726167652e737667)](https://shepherd.dev/github/uzdevid/yii-runner-centrifugo)[![psalm-level](https://camo.githubusercontent.com/1a6e69dea08dbb7700de551a36c01397f368d99f7a0cfac09f89812d6f65bbb3/68747470733a2f2f73686570686572642e6465762f6769746875622f757a64657669642f7969692d72756e6e65722d63656e7472696675676f2f6c6576656c2e737667)](https://shepherd.dev/github/uzdevid/yii-runner-centrifugo)

The package is designed to process web sockets on the basis of [Centrifugo](http://centrifugal.dev/) and [Roadrunner](https://roadrunner.dev/)

Requirements
------------

[](#requirements)

- PHP 8.1 or higher.

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

[](#installation)

The package could be installed with [Composer](https://getcomposer.org):

```
composer require uzdevid/yii-runner-centrifugo
```

General usage
-------------

[](#general-usage)

### Centrifugo

[](#centrifugo)

Download binary [file](https://centrifugal.dev/docs/getting-started/installation)

Generate Centrifugo config file: `config.json`

```
./centrifugo genconfig
```

Example config

```
{
  "log": {
    "level": "debug"
  },
  "client": {
    "token": {
      "hmac_secret_key": ""
    },
    "allowed_origins": [
      "*"
    ],
    "proxy": {
      "connect": {
        "enabled": true,
        "endpoint": "grpc://127.0.0.1:30000",
        "timeout": "10s"
      },
      "refresh": {
        "enabled": true,
        "endpoint": "grpc://127.0.0.1:30000",
        "timeout": "3s"
      }
    }
  },
  "channel": {
    "namespaces": [
      {
        "name": "",
        "allow_subscribe_for_client": true,
        "allow_publish_for_client": true,
        "subscribe_proxy_enabled": true,
        "publish_proxy_enabled": true
      }
    ],
    "proxy": {
      "subscribe": {
        "endpoint": "grpc://127.0.0.1:30000",
        "timeout": "3s"
      },
      "publish": {
        "endpoint": "grpc://127.0.0.1:30000",
        "timeout": "3s"
      },
      "sub_refresh": {
        "endpoint": "grpc://127.0.0.1:30000",
        "timeout": "3s"
      }
    }
  },
  "admin": {
    "enabled": true,
    "password": "",
    "secret": ""
  },
  "grpc_api": {
    "address": "127.0.0.1",
    "port": 30000
  }
}
```

> We set up the proxy for all requests for our Roadrunner server at `grpc://127.0.0.1:30000`, according to the gRPC protocol

See also:

---

### RoadRunner

[](#roadrunner)

Download roadrunner binary [file](https://docs.roadrunner.dev/docs/general/install)

Road runner example config: `.rr.yaml`

```
version: '3'

rpc:
    listen: tcp://127.0.0.1:6001

server:
    command: "php ./worker.php"
    relay: pipes

centrifuge:
    proxy_address: tcp://127.0.0.1:30000
    grpc_api_address: tcp://127.0.0.1:30000
    use_compressor: true

service:
    centrifuge:
        service_name_in_log: true
        remain_after_exit: true
        restart_sec: 1
        command: "./centrifugo"
```

> We listen to the proxies in the address `tcp://127.0.0.1:30000` from the Centrifugo server

---

### Runner file

[](#runner-file)

Create `/worker.php` file

```
use RoadRunner\Centrifugo\Request\RequestFactory;
use Spiral\RoadRunner\Worker;
use UzDevid\Yii\Runner\Centrifugo\CentrifugoApplicationRunner;
use Yiisoft\ErrorHandler\ErrorHandler;
use Yiisoft\ErrorHandler\Renderer\PlainTextRenderer;
use Yiisoft\Log\Logger;
use Yiisoft\Log\Target\File\FileTarget;

ini_set('display_errors', 'stderr');

require_once dirname(__DIR__) . '/vendor/autoload.php';

$logger = new Logger([new FileTarget(sprintf('%s/runtime/logs/centrifugo.log', __DIR__))]);
$errorHandler = new ErrorHandler($logger, new PlainTextRenderer());

$worker = Worker::create(logger: $logger);

$application = new CentrifugoApplicationRunner(
    rootPath: __DIR__,
    temporaryErrorHandler: $errorHandler,
    worker: $worker,
    requestFactory: new RequestFactory($worker),
    debug: true
);

$application->run();
```

### Handlers

[](#handlers)

Handling connect request and response with specific payload

```
use UzDevid\Yii\Runner\Centrifugo\Handler\ConnectHandlerInterface;
use RoadRunner\Centrifugo\Payload\ConnectResponse;

class ConnectHandler implements ConnectHandlerInterface {
    public function handle(RequestInterface $request): void {
        // ...

        $request->respond(new ConnectResponse('user-id', null, ['ok' => true]))
    }
}
```

In the same way, implement the rest of the handlers:

- `ConnectHandlerInterface` - called when a client connects to Centrifugo, so it's possible to authenticate user, return custom initial data to a client, subscribe connection to server-side channels, attach meta information to the connection, and so on. This proxy hook available for both bidirectional and unidirectional transports.
- `RefreshHandlerInterface` - called when a client session is going to expire, so it's possible to prolong it or just let it expire. Can also be used as a periodical connection liveness callback from Centrifugo to the app backend. Works for bidirectional and unidirectional transports.
- `SubscribeHandlerInterface` - called when clients try to subscribe on a channel, so it's possible to check permissions and return custom initial subscription data. Works for bidirectional transports only.
- `PublishHandlerInterface` - called when a client tries to publish into a channel, so it's possible to check permissions and optionally modify publication data. Works for bidirectional transports only.
- `SubRefreshHandlerInterface` - called when a client subscription is going to expire, so it's possible to prolong it or just let it expire. Can also be used just as a periodical subscription liveness callback from Centrifugo to app backend. Works for bidirectional and unidirectional transports.
- `InvalidRequestInterface` - Handle invalid request
- `RpcHandlerInterface` - called when a client sends RPC, you can do whatever logic you need based on a client-provided RPC method and data. Works for bidirectional transports only (and bidirectional emulation), since data is sent from client to the server in this case.

> See also:

### Run RoadRunner

[](#run-roadrunner)

```
./rr serve
```

You can test the [WebSocketing](https://websocketking.com/) service or use the [Client SDK](https://centrifugal.dev/docs/transports/client_api)

Documentation
-------------

[](#documentation)

- [Internals](docs/internals.md)

If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).

Maintained by [UzDevid](https://uzdevid.com/).

Follow updates
--------------

[](#follow-updates)

[![Official website](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](https://www.yiiframework.com/)[![Twitter](https://camo.githubusercontent.com/d077c362ac639792171af8bc002ee827816733dfc0925f70b557e6d151022226/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d666f6c6c6f772d3144413146323f6c6f676f3d74776974746572266c6f676f436f6c6f723d314441314632266c6162656c436f6c6f723d3535353535353f7374796c653d666c6174)](https://twitter.com/yiiframework)[![Telegram](https://camo.githubusercontent.com/4e38dd12535575c39c65bea7119b95e663abb2d1f4e3d669a27bbda07ef603f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d74656c656772616d)](https://t.me/yii3en)[![Facebook](https://camo.githubusercontent.com/48204e301b34b29b0815854544f04c337fc0692096cab35e9a1f8c53a42c2307/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66616365626f6f6b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d66616365626f6f6b266c6f676f436f6c6f723d666666666666)](https://www.facebook.com/groups/yiitalk)[![Slack](https://camo.githubusercontent.com/1a3645ba1c97e6684d0349bc478201e1621ba0d3efad516d81035364d442bad7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d736c61636b)](https://yiiframework.com/go/slack)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance51

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

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://avatars.githubusercontent.com/u/104216283?v=4)[UzDevid](/maintainers/uzdevid)[@uzdevid](https://github.com/uzdevid)

---

Top Contributors

[![DikoIbragimov](https://avatars.githubusercontent.com/u/167644693?v=4)](https://github.com/DikoIbragimov "DikoIbragimov (12 commits)")

### Embed Badge

![Health badge](/badges/uzdevid-yii-runner-centrifugo/health.svg)

```
[![Health](https://phpackages.com/badges/uzdevid-yii-runner-centrifugo/health.svg)](https://phpackages.com/packages/uzdevid-yii-runner-centrifugo)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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