If you have read my previous posts. Maybe the terms Inversion of Control, Dependency injection, DI Containers and Service Locator means anathema, so this article doesn’t suite you.
If you think the whole DI idea is a hoax, no problem. Enjoy the other millions patterns that the OOP world offers.
For people that understand the matter, I would love to hear everything you need to say about it. As I said in my first post: The PHP community makes that language so fun to deal with. I look forward to increase my knowledge and share my own. The general idea of this blog.
Note to the newbies – I won’t give an exact implementation of a problem you’ve faced – I’m not StackOverflow and I don’t intend to be. Yeah I’ll try to help and explain if you have questions about the subject but again, I am not a guru 😉
In the previous part we’ve found a solution for one of the problems, and that is the removing of the dependencies and code it with an interface. By itself, this is a good milestone but we’ve never managed the object creation. The complexity of creating the dependencies through the other objects – so in order to instantiate Payment we need to create every class that must be injected and implement the PaymentProcessor,the Invoice and DB.
So, a little while ago, when I’ve dug in deep into the sea of OOP, a popular new technique surfaced and its called Dependency Injection. Take note here, that I’m not rediscovering the wheel here. Just pointing the obvious and explaining it – My Way!
There are literally thousands of information about that topic, but I’ll try to be brief here, take a little as much I can of your time, and give you all the info, so when you set sail in the vast sea of Information Technologies, you don’t like your support.
In this post, I’ll try to answer questions given by a company for the title “PHP Web Developer”. The questions are all about our field of interest, like SQL and PHP but I’ll try to explain only the PHP with the OOP (Object oriented programming) ones.
Take note here, that these questions has relative brief description, and the idea is to give as much as you can in like 20 or few lines. For everything else, there is Google 😉