xsites / laravel-socket.io
Laravel Socket.io 广播器
v0.1.0
2016-05-02 06:24 UTC
Requires
- php: >=5.6.4
- exls/socket.io-emitter: ^0.1
- illuminate/broadcasting: ^5.2
- illuminate/support: 5.*
Requires (Dev)
- phpunit/phpunit: 4.2.*
Suggests
- illuminate/support: Required for Laravel support
This package is not auto-updated.
Last update: 2024-09-20 19:04:26 UTC
README
安装
通过Composer引入此包。
composer require xsites/laravel-socket.io
Laravel 5.* 集成
将服务提供者添加到您的 config/app.php
文件
'providers' => array( //... Xsites\LaravelSocketIO\Providers\SocketIOServiceProvider::class, ),
配置
将广播器添加到您的 config/broadcasting.php
文件
// Set here the new broadcast connection 'default' => 'socket-io', //... 'connections' => [ // Add additional connection for socket.io broadcaster 'socket-io' => [ 'driver' => 'socket.io', 'redis' => [ //set the redis connection 'connection' => 'default', ], ], //... ],
用法
请参阅官方文档 https://laravel.net.cn/docs/5.1/events#broadcasting-events
示例
class Test extends Event implements ShouldBroadcast { /** * @var array */ public $data; /** * Create a new event instance. * * @param mixed $data */ public function __construct($data) { $this->data = $data; } /** * Get the channels the event should be broadcast on. * * @return array */ public function broadcastOn() { return ['test-channel-name']; } } ... //In your BLL Event::fire(new Test(['param1' => 'value'1])); // Event::fire(new Test(123));
联系方式
Anton Pavlov
- 电子邮件:anton@xsites.co.il