Laravel - Events - Manually Registering Events
Typically, events should be registered via the EventServiceProvider
$listen
array; however, you may also register class or closure based event listeners manually in the boot
method of your EventServiceProvider
:
use App\Events\PodcastProcessed;
use App\Listeners\SendPodcastNotification;
use Illuminate\Support\Facades\Event;
/**
* Register any other events for your application.
*
* @return void
*/
public function boot()
{
Event::listen(
PodcastProcessed::class,
[SendPodcastNotification::class, 'handle']
);
Event::listen(function (PodcastProcessed $event) {
//
});
}