Package Data | |
---|---|
Maintainer Username: | xsites |
Maintainer Contact: | anton@xsites.co.il (Anton Pavlov) |
Package Create Date: | 2016-05-02 |
Package Last Update: | 2016-05-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-05-02 03:03:30 |
Package Statistics | |
---|---|
Total Downloads: | 1,434 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 9 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Pull this package in through Composer.
composer require xsites/laravel-socket.io
Add the service provider to your config/app.php
file:
'providers' => array(
//...
Xsites\LaravelSocketIO\Providers\SocketIOServiceProvider::class,
),
Add the broadcaster to your config/broadcasting.php
file:
// 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',
],
],
//...
],
See the official documentation https://laravel.com/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