Package Data | |
---|---|
Maintainer Username: | ArnisLielturks |
Maintainer Contact: | arnis.lielturks@gmail.com (Arnis Lielturks) |
Package Create Date: | 2017-04-24 |
Package Last Update: | 2017-04-27 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:01:31 |
Package Statistics | |
---|---|
Total Downloads: | 224 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
composer require arnislielturks/faye-laravel-broadcaster
// 'providers' => [
ArnisLielturks\FayeBroadcaster\FayeBroadcasterProvider::class,
// ];
return [
'server' => 'http://127.0.0.1:8000'
];
default' => env('BROADCAST_DRIVER', 'faye'),
OR set this value in .env file
BROADCAST_DRIVER=faye
class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
//All public attributes will be sent with the message
public $id;
public $event = 'test_event';
public function __construct()
{
$this->id = 123;
}
public function broadcastOn()
{
//List of channels where this event should be sent
return ['/test_event'];
}
}
class TestController extends Controller
{
public function test() {
event(new TestEvent());
return view('main');
}
}
Outgoing message to the /test_event channel will look something like this:
{
id: 123,
event: 'test_event',
socket: null,
event_object: 'App\\Events\\TestEvent'
}
That's it!