Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mouse's avatar
Level 1

How to set Laravel 11 with Reverb and Valet

I have a project using Laravel 11. I installed broadcasting too with Reverb. When I open it with Valet, I see these on network/ws:

{"event":"pusher:connection_established","data":"{\"socket_id\":\"807491240.32280726\",\"activity_timeout\":30}"}	

{"event":"pusher:subscribe","data":{"auth":"","channel":"messages"}}	

{"event":"pusher_internal:subscription_succeeded","data":"{}","channel":"messages"}	

and ping pong...

But when I send a message event, it does not displayed. What should do on my project?

BROADCAST_CONNECTION=reverb
QUEUE_CONNECTION=database
REVERB_APP_ID=123456
REVERB_APP_KEY=somethingreverbkey
REVERB_APP_SECRET=somethingreverbsecret
REVERB_HOST=${APP_DOMAIN}
REVERB_PORT=8080
REVERB_SCHEME=https

reverb.php

broadcasting.php

'connections' => [

        'reverb' => [
            'driver' => 'reverb',
            'key' => env('REVERB_APP_KEY'),
            'secret' => env('REVERB_APP_SECRET'),
            'app_id' => env('REVERB_APP_ID'),
            'options' => [
                'host' => env('REVERB_HOST'),
                'port' => env('REVERB_PORT', 443),
                'scheme' => env('REVERB_SCHEME', 'https'),
                'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
            ],
            'client_options' => [
                'verify' => false
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],

Events/MessageSent.php

class MessageSent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     */
    public function __construct(public string $txt)
    {
        //
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel
     */
    public function broadcastOn(): Channel
    {
        return new Channel('messages');
    }
}

echo.js

import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'reverb',
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});


window.Echo.channel('messages')
    .listen('MessageSent', (e) => {
        console.log(e);
    });
0 likes
0 replies

Please or to participate in this conversation.