Skip to main content
Quick Tip

Discover all events fired in one request

If you want to implement a new listener to a specific event but you don't know its name, you can log all events fired during the request.

You can use the \Illuminate\Support\Facades\Event::listen() method on boot() method of app/Providers/EventServiceProvider.php to catch all events fired.

Important: If you use the Log facade within this event listener then you will need to exclude events named Illuminate\Log\Events\MessageLogged to avoid an infinite loop. (Example: if ($event == 'Illuminate\\Log\\Events\\MessageLogged') return;)

// Include Event...
use Illuminate\Support\Facades\Event;
 
// In your EventServiceProvider class...
public function boot()
{
parent::boot();
Event::listen('*', function ($event, array $data) {
// Log the event class
error_log($event);
// Log the event data delegated to listener parameters
error_log(json_encode($data, JSON_PRETTY_PRINT));
});
}

Tip given by @MuriloChianfa

Enjoyed This Tip?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.