I'm new to using laravel pusher I've followed the documentation and watch some tutorials on how to use it but somehow I cant get it work. I'm using laravel 5.6 on, php7.1 and nginx.
I've added all the pusher keys in my .env file already, below are some of my codes
web.php
use App\Events\TestEvent;
Route::get('/test', function() {
TestEvent::dispatch();
});
broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
],
],
TestEvent.php
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
public $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
$this->user = ['name' => 'Test User', 'email' => 'testuser@mail.com'];
$this->message = 'Hello world';
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('TestChannel');
}
}
When I tried to access the route /test on my app I expected that Pusher debug console logs anything but it doesn't, even Pusher error log.
Any help would be much appreciated. Thanks!!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire