Back Button Laravel

Get Real With Laravel Echo

Wouldn't it be great if you could alert the users of your application about important changes, without requiring that they manually refresh the page? What if an order status automatically refreshed itself? What if a thread could instantly render new incoming replies? All of this is a cinch if we leverage Laravel events, Pusher, and Laravel Echo.

8 episodes
1:09:06 hrs
Start Series
    1. Run Time 7:04 Free

      Let's begin by scaffolding a new Laravel app, and pulling in the necessary dependencies to begin broadcasting server-side events to the client.

    2. Run Time 4:44 Free

      Now that we understand how to broadcast an event, let's switch from the log driver over to something more exciting: Pusher. In this episode, we'll learn how to fire a Laravel event, and send it straight to Pusher.

    3. Now that server-side events are properly being sent to Pusher, let's tackle the next layer of the onion. Using Laravel Echo (and the pusher-js library), we'll open a channel and listen for all relevant messages. If one comes through, we can immediately alert the user. This way, the user can be notified of important changes, without needing to manually refresh the page.

    4. Run Time 13:15 Free

      Now that we understand the basic flow for broadcasting an event, let's make things a bit more visual. Imagine that you're working on a task list with a friend or spouse located anywhere in the world. Wouldn't it be nice if, each time you add a new task, they will be notified immediately? This way, you can both flesh out your project in real-time, without needing to constantly refresh your respective browsers to review any updates.

    5. As a basic rule, if the event you're broadcasting is sensitive in nature (order details, direct messaging, etc.), then you should reach for a PrivateChannel. This way, you can assign special authorization rules for the message. Let's review why this is so important.

    6. Run Time 11:18

      Now that we understand what the problem is, we can implement a solution. In this episode, we'll switch to using a private channel. As part of this process, we can also specify any number of broadcasting authorization rules within routes/channels.php.

    7. From time to time you'll want to trigger an event that is dispersed to all fellow clients connected to your private Pusher channel, without going through your backend server. A common example of this is the "JohnDoe is typing..." feedback you might receive when a friend is typing a text message reply. Let's review exactly how to allow for such functionality in this episode.

    8. Run Time 6:37 Free

      Presence channels build upon private channels, by providing extra awareness functionality. The most common example of this is a basic chat room. If we need to track all users, detect when new people join, or when others exit the room, a presence channel is precisely what you need. Let's add a similar feature to our project view.