Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History
New Proposal Template
This page has been created from a template that uses "zones." To proceed:
  1. Edit the page
  2. Replace sample content within each zone-data tag
  3. Remove this notice
  4. Save the page
  5. When you are ready for review, remove the Under Construction notice
Under Construction
This proposal is under construction and is not ready for review.

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_DI Component Proposal Component Proposal

Proposed Component Name Zend_DI Component Proposal
Developer Notes Component Proposal
Proposers My E-mail Address
Revision 0.1 - 21 November 2007: Initial Proposal. (wiki revision: 2)

Table of Contents

1. Overview

Zend_DI is a dependency injector component, similar in concept to PicoContainer, but smaller and easier to use. The architecture of the Zend_DI component is based on the following concepts:

  • Dependency injection is a technique that consists of passing dependencies via the constructor or setter methods.
  • The Container provides an easy way of re-configuring a package to use custom implementations of components.
  • Responsibility for object management is taken over by whatever container is being used to manage those objects.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will ...
  • This component will not ...

4. Dependencies on Other Framework Components

  • Zend_Exception
  • ReflectionClass

5. Theory of Operation

The purpose of Zend_DI is to provide and easier way to test atomic units of code in isolation, and to mock dependencies which one component may refer to. Zend_DI minimizes coupling between groups of classes, makes unit testing much simpler, and provides an easy way to re-configure a library to use custom implementations of components.

Zend_DI provides generic factory classes that instantiate instances of classes. These instances are then configured by the container, allowing construction logic to be reused on a broader level. Typically, responsibility for object management is taken over by whatever container is being used to manage those objects.

6. Milestones / Tasks

  • Milestone 1: Proposal finished
  • Milestone 2: Proposal accepted
  • Milestone 3: Working release
  • Milestone 4: Unit tests
  • Milestone 5: Documentation
  • Milestone 6: Future enhancements

7. Class Index

  • Zend_DI_Container
  • Zend_DI_Exception
  • Zend_DI_Container_Manager
  • Zend_DI_Container_Exception
  • Zend_DI_Container_Registry
  • Zend_DI_Container_Registry_Interface
  • Zend_DI_Component_Factory
  • Zend_DI_Component_Exception

8. Use Cases

  • Foo.php

class Foo {
public function __construct(
FooInterface Component1 = null,
FooInterface Component2 = null,
arg1 = null,
arg2 = null) {

  • Test.php

$di = new Zend_DI_Container();

// Define a class and create an instance

// Example: Inject dependency

// Example: Inject multiple dependencies
->addDependencies('Component1' [, 'Component2' [, ...]])

// Example: Pass arguments to the constructor

// Or...
->addDependencies('Component1' [, 'Component2' [, ...]])
->addArguments('arg1' [, 'arg2' [, ...]])

// Get an instance of the class
$obj = $di->getInstance('Foo');

9. Class Skeletons


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.