I like the concept behind dependency injection, but I don't really see any worthy benefit in PHP. I think Spring over in Java land is great (especially in sizable projects), I love being able to drop in something, change the depedancy in an XML file, and work away. It's handy for testing and messing around. But Java web applications are compiled. I want make a change I have to go through a sometimes complicated build and deployment process.
Java, also, lives on beyond the first request. The overhead added related to dependency injection is usually short-lived (e.g. quite a lot in many cases is gone after application startup).
PHP, on the other hand, is easy to change the code for and it is destroyed after every request. A service locater just seems more appropriate. I don't like it how it intrudes into the code, but in the end, it just seems more reasonable to me.
I would guess he means using getters/setters instead of requiring the information in the constructor.
Let's keep it out of our personal lives, now.Originally Posted by lastcraft
![]()





Bookmarks