News Feed
Sections




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

Rob Allen's Blog:
An introduction to ZendDi
February 29, 2012 @ 09:16:20

Rob Allen, Zend Framework guru extraordinaire, has posted an introduction to the Dependency Injection container that's a part of Zend Framework 2 - ZendDi.

Zend Framework 2 provides its own dependency injection container, ZendDi which is a key underpinning of the entire framework and especially the MVC system. I have covered before, my thoughts on the reasons for using dependency injection, so this article looks at the fundamentals of using ZendDi.

He includes some sample code showing a current setup involving constructor injection and how it can be refactored to use the new DI container. With the new version, the resource is assigned to the container and that is referenced when a new object type needs to be created. He also briefly touches on setter injections, noting that he prefers them more for optional dependencies and shows how to enable their use in the container as well.

0 comments voice your opinion now!
zendframework2 dependency injection zenddi container tutorial


blog comments powered by Disqus

Similar Posts

DevShed: Performing Basic Tasks with MySQL 4.1 and Above, using mysqli with PHP 5

IBM developerWorks: Build a web-based notification tool with XMPP

NetTuts.com: Design Patterns: The Decorator Pattern

WebCheatSheet.com: Secure File Upload with PHP

Zend Developer Zone: Build an Enterprise-Grade PHP Stack with Zend Server 5.0 and Oracle 11g


Community Events

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


list language opinion podcast example programming project interview community api framework series application php7 laravel part2 introduction yii2 composer symfony

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