I hope this question is not duplicated.
In Laravel, how can I register events/listeners to that events outside app/Providers/EventServiceProvider
file? Also, is it possible to register them on-the-fly?
You can register your events, listeners, and subscribers in any Service Provider's boot
method. The EventServiceProvider
just provides convenience specifically for events, but it is just taking these arrays and spinning through them and registering them how you would manually do it anyway.
At any time after the framework has basically ran all the register
methods of the Service Providers you can register events and listeners.