← Back to Course

Event Broadcasting with Pusher and Laravel Echo

Event broadcasting lets server-side events push real-time updates to connected browsers, without the client needing to poll for changes.

The Pieces Involved

PieceRole
PusherHosted WebSocket service that relays broadcast events
Laravel EchoJavaScript library that subscribes to channels in the browser
ShouldBroadcastInterface marking a Laravel event as broadcastable

Making an Event Broadcastable

class OrderShipped implements ShouldBroadcast
{
    public function broadcastOn(): Channel
    {
        return new Channel('orders');
    }
}

Listening in the Browser

Echo.channel('orders')
    .listen('OrderShipped', (e) => {
        console.log(e.order);
    });

Private and Presence Channels

Beyond public channels, Laravel supports private channels (authorized per user) and presence channels (which also track who's currently subscribed) for more controlled real-time features.

Broadcasting covers real-time communication. The next set of topics shifts to code organization patterns that keep larger Laravel applications maintainable.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course