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:
What problem does dependency injection solve?
February 20, 2012 @ 09:37:15

In his latest post Rob Allen seeks to answer the question "what problem does dependency injection solve?":

Zend Framework 2 comes with a dependency injection container (DIC), as does Symfony 2 and Aura, along with many other PHP frameworks that target PHP 5.3 or hight nowadays. This article attempts to explore the problem that a DIC tries to solve.

He gives an example (somewhat based on the same structure of his Zend Framework tutorial) showing how you could use DI to inject the Artist object into the Album object. This allows for more flexibility if more Artist types are added (extending the main Artist, of course). His second example shows how to use a DIC to hold album information.

0 comments voice your opinion now!
dependency injection tutorial example container artist album


blog comments powered by Disqus

Similar Posts

Maarten Balliauw's Blog: Using Windows Azure Drive in PHP (or Ruby)

Web Builder Zone: Real-life closures examples...for real

Matthias Noback: Symfony2: Add a global option to console commands and generate a PID file

Community News: Welovelocal.com offers SOAP API (with PHP examples)

Lars Strojny's Blog: Dependency Injection Container Refactorings, Part Two


Community Events

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


library interview laravel api voicesoftheelephpant conference series php7 opinion framework example introduction podcast application performance release symfony2 version extension community

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