Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Removed var_dumps()

latest commit 076f2b89b7
Ralph Schindler authored April 18, 2012
Octocat-spinner-32 10 First commit of use cases for Zend\Di October 06, 2011
Octocat-spinner-32 11 Added use cases for compiler interface injection and annotation injec… October 06, 2011
Octocat-spinner-32 12 Added use cases for compiler interface injection and annotation injec… October 06, 2011
Octocat-spinner-32 includes Added example number 16 (Builder definition example) January 09, 2012
Octocat-spinner-32 README.md Added absolute links to the README.md November 01, 2011
Octocat-spinner-32 example-01.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-02.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-03.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-04.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-05.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-06.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-07.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-08.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-09.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-10.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-11.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-12.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-13.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-14.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-15.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-16.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-17.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-18.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-19.php Example 19 added: shared support March 16, 2012
Octocat-spinner-32 example-20.php Added example of preference to Zend\Di Examples March 19, 2012
Octocat-spinner-32 example-21.php Removed var_dumps() April 18, 2012
Octocat-spinner-32 zf2bootstrap.dist.php Updated examples for beta2 usages January 05, 2012
README.md

README

Bootstrapping

Each script will utilize the zf2bootstrap.dist.php file located in this directory. If you want to override this file, simply copy it to zf2bootstrap.php in the current working directory, or inside of your configured include_path.

Most of the examples here build off of the "Movie and Lister" example put forth by Martin Fowler in his post located at http://martinfowler.com/articles/injection.html.

Example Index

Example 01 - Constructor Injection

Simple Constructor Injection. Object obtained from the container by using the class name.

✍ source

Example 02 - Interface Injection

Interface Injection via runtime definition.

✍ source

Example 03 - Setter Injection

Setter injection via runtime definition. The setter method has to be marked as such so that the container knows that the setter is non-optional.

✍ source

Example 04 - Configuration Parameters

Constructor injection with configuration parameters passed into the instance manager.

✍ source

Example 05 - Call-time Parameters

Constructor injection with parameters passed into the containers get() method.

✍ source

Example 06 - Setter Injection With Configuration

Setter injection with configuration. With this form of setter injection, the setter is originally optional, but since parameters that fulfill this method are passed into the configuration, the setter will be called.

✍ source

Example 07 - Setter Injection With Call-time Parameters

setter-injection-with-calltime-params

✍ source

Example 08 - Multiple Injections / Single Injection Point

The ability to inject objects/dependencies of the same type through a single injection point. This is sometimes called re-injection.

✍ source

Example 09 - Setter Injection With Annotation

Setter injection specified by an annotation. By default, setters are identified but marked as optional. By using the Inject() annotation, this will mark the method as required.

✍ source

Example 10 - Compiler Based Constructor Injection

Compiler based constructor injection

✍ source

Example 11 - Compiler Based Interface Injection

Compiler based interface injection

✍ source

Example 12 - Compiled Based Setter Injection With Annotation

Compiler based setter injection using annotations.

✍ source

Example 13 - Closure based dependency

The ability to specific a method that can be called to satisfy a dependency. This is useful when the dependency is not managed by the container, but perhaps by another container or some other outside system (service locator).

✍ source

Example 14 - Disambiguation

When two methods have the same parameter signature, use the fully qualified name for the parameters instead of the given name.

✍ source

Example 15 - Multiple Injection to Single Injection Point With Multiple Arguments

When a method must be called multiple times (sometimes called reinjection), and there are multiple values that need to be passed along with the dependency.

✍ source

Something went wrong with that request. Please try again.