Skip to main content

What are events?

Laravel’s event system implements the observer pattern. When something notable happens in your application—an order ships, a user registers—you dispatch an event. One or more listeners respond to that event independently. This decouples your core business logic from side effects like sending emails or updating analytics. You can add, remove, or change listeners without touching the code that raised the event.

Generating events and listeners

Use Artisan to scaffold events and listeners:
Running the commands without arguments prompts you interactively for names.

Registering events and listeners

Event discovery (automatic)

By default, Laravel scans app/Listeners automatically and registers any listener method that begins with handle or __invoke. The event it listens to is determined by the type-hint in the method signature:
No manual registration needed. Cache the manifest before deploying to production:

Manual registration

Register events manually inside AppServiceProvider::boot using the Event facade:

Closure listeners

Register a closure directly for lightweight, one-off reactions:

Defining events

An event is a data container. It holds the information needed by listeners—nothing more:
SerializesModels ensures Eloquent models serialize correctly when the event is used with a queued listener.

Defining listeners

Listeners receive the event in their handle method. The service container injects any constructor dependencies automatically:
Return false from handle to stop the event from propagating to other listeners.

Dispatching events

Call dispatch on the event class:
Dispatch after the current database transaction commits, so listeners only run when the data is actually saved:

Queued listeners

Listeners that send emails or call external APIs should run in the background. Implement ShouldQueue to push the listener onto the queue automatically:
Customize the queue connection and name:

Queueable closure listeners

Wrap a closure with queueable to run it on the queue:

Event subscribers

An event subscriber is a single class that handles multiple events. Implement a subscribe method and register the class:
Register the subscriber in AppServiceProvider::boot:

End-to-end example

1

Create the event

2

Create the listener

3

Dispatch from the controller

Testing events

Fake all events to assert they were dispatched without triggering listeners:

Queues

Learn how to run queued listeners and background jobs at scale.
Last modified on April 19, 2026