1. Go to this page and download the library: Download xsites/laravel-socket.io library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// 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',
],
],
//...
],
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));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.