In this episode, we're diving into setting up broadcasting in our API. We start by heading over to the API project and running a PHP Artisan command to install the broadcasting features. You'll see a prompt asking if we want to install Laravel Reverb—which is what we'll use throughout the course. If you prefer something like Pusher, you could swap it out with just a few configuration changes.
Next, we talk about node dependencies. Since we're working with an API, we don't need to install the JavaScript dependencies (like Laravel Echo or Pusher) here, because those will live in the frontend (client) instead. If you were working on a full Laravel app with blade views, this step would be necessary, but we're going to skip it.
Once the install is done, we peek into our Laravel environment file and see that the broadcasting connection is set to Reverb automatically, along with some sensible defaults. There's a new app key, host, and port that will be important later when we connect our client to the Reverb server. No tweaks are needed unless you're pushing to production.
With the environment set up, we go ahead and start the Reverb server using the php artisan reverb:start
command—feel free to add --debug
if you want extra output to help with troubleshooting. Now, the server is listening for events, and it's ready for our Nuxt client to connect and start receiving real-time updates from the API. In the next step, we'll hop over to our Nuxt app to get it listening for those broadcast events using Laravel Echo.