larva / pusher-sdk
The official Pusher Server PHP SDK.
1.0.7
2024-05-10 12:12 UTC
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3.1|^7.0
Requires (Dev)
- phpunit/phpunit: ^8.4|^9.0
README
Introduction
Pusher 服务 Sdk
Official Documentation
安装
To install the SDK in your project you need to require the package via composer:
composer require larva/pusher-sdk
基本使用
您可以创建这样的SDK实例:
$forge = new Larva\Pusher\Forge('http://ws.domain.com', TOKEN_HERE);
发布点对点事件:
$res = $forge->publish('6557749ee6d95#32131','event', ['name'=>'张三']);
向频道广播事件:
$res = $forge->trigger('room1','event', ['name'=>'张三']); //或者 $channel = $forge->channel('room1'); $channel->trigger('event', ['name'=>'张三']);
查询频道在线人数:
$channel = $forge->channel('room1'); $channel->online_users;
License
Larva Forge SDK is open-sourced software licensed under the MIT license.