atfinho
2 months ago

Send event to pusher ( laravel 5.7)

Posted 2 months ago by atfinho

Hey guys I'm trying to send an event to pusher but it's not working , it's always displaying " Waiting for events..."

here is my code

Routes:

Route::get('/pusher', function() {
    event(new App\Events\CreatePost('Hi there Pusher!'));
    return "Event has been sent!";
    });


.env:

PUSHER_APP_ID=app_id
PUSHER_APP_KEY=app_key
PUSHER_APP_SECRET=app_secret
PUSHER_APP_CLUSTER=eu


Event:

<?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 CreatePost implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

   public $post;

   
   
    public function __construct($post)
    {
         $this->post=$post;
    }

    public function broadcastOn()
    {
        return new Channel('Post');
    }
}



I added my credentials to .env file changed BROADCAST_DRIVER -> pusher

ran php artisan config:cache for many times.. it doesn't work

Please sign in or create an account to participate in this conversation.