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.
Simple Constructor Injection. Object obtained from the container by using the class name.
Interface Injection via runtime definition.
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.
Constructor injection with configuration parameters passed into the instance manager.
Constructor injection with parameters passed into the containers get()
method.
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.
setter-injection-with-calltime-params
The ability to inject objects/dependencies of the same type through a single injection point. This is sometimes called re-injection.
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.
Compiler based constructor injection
Compiler based interface injection
Compiler based setter injection using annotations.
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).
When two methods have the same parameter signature, use the fully qualified name for the parameters instead of the given name.
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.