You're right, you don't need to put anything in the provides()
method since you aren't binding anything with register()
.
I believe provides()
is only used for deferred service providers, i.e. service providers that don't get run when the framework boots, but when a service they provide is requested from the IoC container. When Laravel compiles, it checks what services each deferred service provider provides, caches that in the storage/meta/services.json file which can then be looked up to find out which service provider class to execute to get the requested binding registered.
I've been reading around and I thought it would be something like this.
There are various tutorials on creating a Laravel's package, but none of them talks about the purpose of the provides()
method. It's clearer to me now.
Thanks maknz!
Its clearly describe the purpose of provides method in ServiceProvider class.
please have a look to https://laravel.com/docs/5.4/providers#deferred-providers
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community