devnotes.

Events, Listeners, and Broadcasting

Events provide a simple observer pattern for decoupling different parts of your application — one action can trigger multiple independent side effects without the triggering code knowing about any of them.

php artisan make:event OrderShipped
php artisan make:listener SendShipmentNotification --event=OrderShipped
class OrderShipped
{
    public function __construct(public Order $order) {}
}

class SendShipmentNotification
{
    public function handle(OrderShipped $event): void
    {
        Mail::to($event->order->user)->send(new ShipmentMail($event->order));
    }
}

Dispatching an event:

event(new OrderShipped($order));
// or
OrderShipped::dispatch($order);

Modern Laravel auto-discovers listeners defined with the #[AsListener] attribute or registered via events without needing a manual EventServiceProvider map. Mark a listener with implements ShouldQueue to have it processed asynchronously, exactly like a job.

Broadcasting takes events one step further, pushing them to the browser in real time over WebSockets using Laravel Reverb (Laravel's own first-party WebSocket server) or Pusher — perfect for live notifications, chat, and dashboards, paired with Laravel Echo on the frontend.

Laravel Events, Listeners & Real-Time Broadcasting | DevNotes