Are there any Guice like or similar dependency injection frameworks in PHP? If not are there any good dependency injection frameworks in PHP?
I have to implement same code in PHP what I have implemented in Java and I use Guice in my Java project. So it would be easier to implement PHP version, if it used similar framework.
Disadvantages of Dependency Injection:Dependency injection creates clients that demand configuration details to be supplied by construction code. This can be difficult when obvious defaults are available. Dependency injection can make code difficult to trace (read) because it separates behaviour from construction.
Object Oriented ProgrammingPHPProgramming. Dependency injection is a procedure where one object supplies the dependencies of another object. Dependency Injection is a software design approach that allows avoiding hard-coding dependencies and makes it possible to change the dependencies both at runtime and compile time.
The Symfony DependencyInjection component provides a standard way to instantiate objects and handle dependency management in your PHP applications. The heart of the DependencyInjection component is a container which holds all the available services in the application.
(Posting my comment as a response)
Have a look at my clone of Guice named Sharbat (means juice). The API is quite the same as Guice's.
It has pretty much everything you need:
See the readme file for example usage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With