Laravel DeferrableProvider not working

Title was a bit clickbaity but perhaps this will save someone else some time.

Put simply, the ‘register’ method on a service provider class is always called when executing from a php artisan context. This is not explained anywhere in the service provider documentation. The ‘Deferred Providers‘ section of the documentation does not explicitly call this out, and it cost me some time last night debugging an issue.

*WHY* this is, I’m not quite sure, but it can certainly cause some confusion as to why code operates one way via http requests and one way via console execution. If/when I have time I may add a bit more to this, but just dropping this note here for now…

Leave a Reply

Your email address will not be published. Required fields are marked *