Laravel event-driven architecture with listeners

Carlos Mendez Jan 2026
4 tabs
<?php

namespace App\Events;

use App\Models\Order;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderPlaced
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public function __construct(
        public Order $order
    ) {}
}
4 files · php Explain with highlit

Events and listeners decouple application logic, making code modular and testable. When significant actions occur—user registered, order placed—I fire events. Multiple listeners can respond to one event without the event knowing about them. Events are simple data containers extending Illuminate\Foundation\Events\Dispatchable. Listeners implement handle() methods receiving the event. Queueable listeners process asynchronously via ShouldQueue. The EventServiceProvider maps events to listeners. This pattern enables side effects like sending emails, logging, or updating statistics without cluttering core business logic. Observers simplify Eloquent model events. Event discovery automatically registers listeners without manual mapping.