Dependency Injection in Zend Framework
The Zend Framework is a step closer to having its own DI Container.
Bradley Holt has announced the creation of a new proposal Zend_Container, a simplified version of Zend_Di. According to him, if the framework is going to have a dependency injection component this component needs to be as simple as possible, something along the lines of PicoContainer.
Zend_Container goals:
- The component’s primary purpose is to replace the use of class-managed singletons and Zend_Registry.
- The component will only manage singleton items within a container, it will not act as a factory (except for creating the single instance).
- A container can have zero or one parent container and have access to items in its parent, but a parent cannot have access to items in its children.
- The component uses reflection to determine dependencies.
The Xyster team has already implemented a similar component, Xyster_Container, a Dependency Injection container based very heavily on PicoContainer, however the main goal of Zend_Container is simplicity.
The good news is that, for the first time, Zend has given the official go-ahead for the development of this component.
More info: Dependency Injection in Zend Framework
Federico – thanks for writing about this! Just for clarification, my proposal is only a draft and has _not_ in any way been approved by Zend.
Bradley Holt
July 29, 2008 at 11:46 am
Yes I know, this comment got me excited though:
Federico
July 29, 2008 at 10:08 pm
Federico – thanks again for your feedback on my proposal! I’ve made a few updates to the proposal this weekend and added some clarifications about the proposal on my blog:
Bradley Holt
August 3, 2008 at 10:18 pm
The fact that Container intends to replace Registry is a good thing, considering that Registry has some design flaws.
I’ve being looking at ZF’s API and the component names are not very consistent. If your component doesn’t support DI, I would recommend you change the name from Container for Storage (like Symfony), to make it less confusing.
Thanks for the update
Federico
August 4, 2008 at 9:14 am