kismia/centrifugo-bundle
Composer 安装命令:
composer require kismia/centrifugo-bundle
包简介
A Centrifugo bundle for Symfony
README 文档
README
This is wrapper for PHP client for Centrifugo real-time messaging server.
Installation
Install the latest version with
composer require kismia/centrifugo-bundle
Register bundle in app\AppKernel.php
public function registerBundles() { $bundles = [ ....... new \Kismia\CentrifugoBundle\CentrifugoBundle() ]; }
Configure centrifugo-bundle. In the config file add the following lines
centrifugo: apiendpoint: 'http//example.com/api/' secret: 'secret api key' transport: redis: host: 'localhost' shards: 6 db: 2 timeout: 0.3 port: 6379 http: []
Basic usage
<?php $userId = 1; $channel = '#chan_1'; $messageData = ['message' => 'Hello, world!']; //instance of Centrifugo client class $centrifugo = $this->get('centrifugo.client'); //Send message into channel. $response = $centrifugo->publish($channel, $messageData); //Very similar to publish but allows to send the same data into many channels. $response = $centrifugo->broadcast($channels, $messageData); //Unsubscribe user from channel. $response = $centrifugo->unsubscribe($channel, $userId); //Disconnect user by user ID. $response = $centrifugo->disconnect($userId); //Get channel presence information (all clients currently subscribed on this channel). $response = $centrifugo->presence($channel); //Get channel history information (list of last messages sent into channel). $response = $centrifugo->history($channel); //Get channels information (list of currently active channels). $response = $centrifugo->channels(); //Get stats information about running server nodes. $response = $centrifugo->stats(); //Get information about single Centrifugo node. $response = $centrifugo->node('http://node1.example.com/api/');
统计信息
- 总下载量: 22.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-22