Can somebody throw some light with a basic working example for a Dependency Injection Container (DIC) in PHP?
I know this is a sort of vague question, I have been going through some examples especially from Fabian Potencier where he explained what is DI in PHP in a good way with a working example.
Apart from Fabian I went through some more articles, but I am in search of a working example for DIC, so that guys like me will get a better understanding with a simple working example.
May be a small explanation why we need to use DIC would also be helpful, like in which context will it come in handy and so.
Thanks
I dont know if you read that article:
http://richardmiller.co.uk/2011/07/07/dependency-injection-moving-from-basics-to-container/
but it helped me to understand the advantages of DI
Richard Miller had also a good presentation about why to use DI:
https://speakerdeck.com/u/richardmiller/p/dependency-injection-and-the-symfony2-service-container
It gives just dummy code examples, but you surely will recognize some real world issues.