News Feed
Sections




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

Luis Atencio's Blog:
Dependency Injection in PHP
June 09, 2012 @ 10:55:36

On his Reflective Thought blog Luis Atencio takes a look at the current state of dependency injection in PHP and shares a simple refactor from non-DI to code that uses it as a service locator.

If you have worked with frameworks such as Spring or Google Guice, you will understand the power and flexibility that dependency injection provides your humongous code base. [...] One quick drawback that I see is that the stateless nature of PHP makes things like object containers not very practical.

He proposes a slightly different kind of dependency injection system, one more akin to what's provided in the Java world where annotation and reflection are components of the integration. He provides a code sample of how this would look and points to Java's JSR-330 standard for some of the annotation examples (like "@inject" or "@scope").

0 comments voice your opinion now!
dependency injection java suggestion container service resource


blog comments powered by Disqus

Similar Posts

Stubbles Blog: My wishlist for PHP 6, pt1: The 'object' type hint

Reddit.com: Dependency injection in ZF2 and Symfony 2 are service locators

PHPMaster.com: Dependency Injection with Pimple

Ibuildings techPortal: DPCRadio: Real World Dependency Injection

ThinkPHP Blog: Performance boost for ZendStudio Windows


Community Events





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


list series interview code threedevsandamaybe podcast install application configure release api bugfix framework laravel developer library wordpress introduction language community

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