tomchanio / php_cent
Centrifugo (Centrifuge) [2.0+] PHP 服务器 REDIS & HTTP API 实现,适用于 Laravel 5.5+
1.4
2021-04-11 19:29 UTC
Requires
- illuminate/container: ^5.5
README
Centrifugo (Centrifuge) [2.0+] PHP 服务器 HTTP API 实现,适用于 Laravel 5.5+
基本安装
- 运行
composer require tomchanio/laravel_cent
&composer update
- 创建以下提供的
config/centrifugo.php
- 在以下提供的
config/app.php
中添加别名
配置示例 config/centrifugo.php
<?php return [ 'url' => 'https://:8000/api/', // full api url 'secret' => 'skoniksnyashamoyanikamuneotdam', // you super secret key 'apikey' => 'skoniksnyashamoyanikamuneotdam', // you api key ];
别名添加 config/app.php
'aliases' => [ ... 'Centrifugo'=> Tomchanio\Centrifugo\Centrifugo::class, ]
[模块使用 || 发送您的请求] 示例
<?php use Centrifugo; class Controller { public function your_func() { // declare Centrifugo $Centrifugo = new Centrifugo(); // generating token example $userid = '1337_1448_228'; $info = ['token' => '123']; $token = $Centrifugo->generateToken($userid, $info); // publishing example $Centrifugo->publish("channel" , ["yout text or even what rou want"]); // each method returns its response; // list of awailible methods: $response = $Centrifugo->publish($channle, $messageData); $response = $Centrifugo->broadcast($channles, $messageData); $response = $Centrifugo->unsubscribe($channle, $userId); $response = $Centrifugo->disconnect($userId); $response = $Centrifugo->presence($channle); $response = $Centrifugo->presence_stats($channle); $response = $Centrifugo->history($channle); $response = $Centrifugo->history_remove($channle); $response = $Centrifugo->channels(); $response = $Centrifugo->info(); $response = $Centrifugo->generateToken($user); // You can create a controller to bild your own interface; }