News Feed
Sections




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

Jakub Zalas' Blog:
Managing object creation in PHP with the Symfony2 Dependency Injection component
September 08, 2011 @ 09:24:55

On his blog today Jakub Zalas has posted a tutorial he's written up about using dependency injection in PHP with the Symfony2 dependency injection component (DIC).

Symfony's DependencyInjection component is a PHP implementation of a Service Container, or as others like to call it, a Dependency Injection Container (DIC). The component also provides useful tools for handling service definitions, like XML loaders or dumpers. If you want to learn more about the dependency injection or the dependency injection container, read an excellent series of articles on the subject by Fabien Potencier: What is Dependency Injection?

He walks you through the entire process - installing the needed libraries (the DIC, a config and class loader component and Buzz, a lightweight HTTP client). Code is included to show object creation the "usual way" and then creating the same types of objects in a dependency injection environment. Also included is a sample XML document describing the services for the container. He finishes the post with a GraphvizDumper-generated image for the container.

0 comments voice your opinion now!
dependency injection symfony2 component services xml tutorial


blog comments powered by Disqus

Similar Posts

Anthony Ferrara: Programming With Anthony - Prepared Statements

ServerGrove Blog: Symfony2 components overview: Templating

Symfony Blog: Symfony 2.0 (Release)

Christoph Dorn's Blog: Profiling queries with Zend_Db_Profiler_Firebug

PHPBuilder.com: Create a Unit Conversion Application w/the Zend_Measure Component


Community Events





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


security conference interview language release laravel voicesoftheelephpant series composer introduction list artisanfiles podcast community symfony tool library version opinion framework

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