News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Christopher Bledsoe's Blog:
PHP Dependency Injection (Inversion of Control)
January 10, 2011 @ 09:39:03

On his ClickMagnate site Christopher Bledsoe has an interesting post looking at dependency injection (or, as he calls it "inversion of control") in PHP applications.

.NET and Java have some great IoC (Inversion of Control) containers but PHP hasn't gotten the same kind of dependency love (I know there are a few people who have tried to tackle this problem but I wanted something that worked with Zend Framework - my framework of choice). I also wanted the dependencies to be defined via the application.ini that Zend Framework uses... So, here's my attempt at that.

He includes both the configuration (Zend Framework based) of his dependency injection (DI) class that lists the classes each instance needs to have injected and the code for the actual DI class. The process looks at the configuration file and, if it finds something with the current class name, creates an instance of the class to inject and push it into the controller.

3 comments voice your opinion now!
dependency injection inversionofcontrol zendframework tutorial


blog comments powered by Disqus

Similar Posts

Hasin Hayder's Blog: RSA Encrypting and Decrypting data with Zend_Crypt_Rsa Library

IBM developerWorks: Developing PHP the Ajax way, Part 1 - Getting started

Zend Developer Zone: Using Zend_Tool to start up your ZF Project

SitePoint PHP Blog: The Joy of Regular Expressions [1]

Zend: Roll Your Own Search Engine with Zend_Search_Lucene


Community Events











Don't see your event here?
Let us know!


framework threedevsandamaybe application overview podcast hack security unittest release code component language hhvm composer package symfony2 introduction install opinion facebook

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework