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
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 01 - Constructor Injection
Simple Constructor Injection. Object obtained from the container by using the class name.
Example 02 - Interface Injection
Interface Injection via runtime definition.
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.
Example 04 - Configuration Parameters
Constructor injection with configuration parameters passed into the instance manager.
Example 05 - Call-time Parameters
Constructor injection with parameters passed into the containers
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.
Example 07 - Setter Injection With Call-time Parameters
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.
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.
Example 10 - Compiler Based Constructor Injection
Compiler based constructor injection
Example 11 - Compiler Based Interface Injection
Compiler based interface injection
Example 12 - Compiled Based Setter Injection With Annotation
Compiler based setter injection using annotations.
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).
Example 14 - Disambiguation
When two methods have the same parameter signature, use the fully qualified name for the parameters instead of the given name.
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.