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

About these ads

5 thoughts on “Dependency Injection in Zend Framework

  1. Yes I know, this comment got me excited though:

    Take a look at Ralph’s Zend_Reflection component for any reflection capability you may need. He’s adding something for docblocks specifically.

  2. 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:

  3. 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s