Events & listeners

Decouple domain actions from notifications and integrations.

Events decouple side effects from domain actions. Dispatch when something meaningful happens; listen when another module should react.

Dispatch

phpapp/Services/ProjectService.php
event(new ProjectCreated($project));

Listen

phpapp/Listeners/SendProjectWelcomeMail.php
class SendProjectWelcomeMail
{
    public function handle(ProjectCreated $event): void
    {
        Mail::to($event->project->owner)->queue(
            new ProjectWelcomeMail($event->project)
        );
    }
}

When to use events

SituationPreferAvoid
Notify other modulesEventsFat controllers
Must succeed with the writeSame transactionAsync listener
Best-effort side effectQueued listenerBlocking mail
Info
Queued listeners inherit job failure handling. Pair them with failed job alerts in production.
  1. Name events in the past tense (ProjectCreated).
  2. Keep payloads serializable.
  3. Register listeners in EventServiceProvider or attributes.

Updated Aug 5, 2026