Posted: 06-04-2019

Laravel Automatic Event Listener Discovery

Laravel Automatic Event Listener Discovery

Laravel 5.8.9 comes with an optional automatic event listener discovery.

You must remember that  Event discovery is an opt-in feature in Laravel 5.8,  so you must explicitly define the following method in your EventServiceProvider class, returning a Boolean true

/**
 * Determine if events and listeners should be automatically discovered.
 *
 * @return bool
 */
public function shouldDiscoverEvents()
{
    return true;
}

In addition has been added event:cache Artisan command. 

Taylor Otwell explains in depth how to implement this new feature on Laravel blog

Additional resources:
Laracast: What's New in Laravel 5.8: Automatic Event Listener Discovery
Laravel News : Laravel 5.8.9 Released
Taylor Otwell: Laravel Snippet #10 Podcast