Hi. Sorry for post in this old thread. But my question is related to the same.
As I understand, Service Providers are useful because:
- they allow us creating new instances than require some configuration
- we can use a contract (or interface) and change the implementation of the service if needed
A service provider is a class that can register bindings in the service container, and provide services in this way.
However, if I have a service with no dependencies (a simple class instantiation), I don't need service providers. Is it?
I have a class CvHandler that I want to use from different locations.
So I was creating a service provider, to be able to use dependency injection.
However, I have not added $this->app->bind(CvHandler::class); to the register method, and the dependency injection is available for this class (it means it is not necessary to use providers for classes with no dependencies, right?).
Edit: It seems that is not necessary to use providers. But how Laravel uses reflection? (What class contains the implementation?)