Git Product home page Git Product logo

zend_di-examples's Introduction

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

zend_di-examples's People

Stargazers

Enrico Zimuel avatar

Watchers

Enrico Zimuel avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.