Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I verify if Reverb is working correctly in my Laravel setup


How do I verify if Reverb is working correctly in my Laravel setup


here are the steps to verify if Reverb is working correctly in your Laravel setup:

1. Start the Reverb server: Run the command `php artisan reverb:start` to start the Reverb server. You can add the `--debug` option to see more detailed logs.

2. Set up a test channel and event: In your `resources/js/echo.js` file, create a test channel and listen for a test event:

javascript
window.Echo.channel("test-channel").listen("TestEvent", (event) => {
    console.log(event);
});

3. Broadcast a test event: Create a `TestEvent` class in your Laravel application and broadcast it to the "test-channel":

php
class TestEvent extends Broadcast
{
    public function broadcastOn(): array
    {
        return ['test-channel'];
    }

    public function broadcastWith(): array
    {
        return [
            'message' => 'Test event received!',
        ];
    }
}

4. Trigger the test event: In a controller or elsewhere in your application, trigger the `TestEvent` to see if it's being received by the client:

php
event(new TestEvent());

5. Check the browser console: Open your browser's developer tools and navigate to the Network tab. You should see WebSocket connections being established and events being received.

6. Check the Reverb server logs: In the terminal where you started the Reverb server, you should see log messages indicating the WebSocket connections and events being processed.

If you see the test event being logged in the browser console and the Reverb server logs, it means Reverb is working correctly in your Laravel setup. If you encounter any issues, double-check your Reverb configuration, including the environment variables, and ensure there are no conflicts with other services.

Remember to remove the test code once you've verified that Reverb is working as expected.

Citations:
[1] https://tapansharma.dev/blog/how-to-install-and-configure-laravel-reverb-on-a-laravel-project
[2] https://github.com/laravel/reverb/issues/107
[3] https://novu.co/blog/the-ultimate-guide-to-laravel-reverb/
[4] https://laravel.com/docs/11.x/reverb
[5] https://laracasts.com/discuss/channels/laravel/reverb-herd-not-working-after-shift-from-laravel-10x-to-11x