Skip to content

Files

Latest commit

author
Dominik Liebler
Sep 24, 2013
0224d6d · Sep 24, 2013

History

History
This branch is 1058 commits behind DesignPatternsPHP/DesignPatternsPHP:main.

DependencyInjection

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 24, 2013
Sep 11, 2013
Sep 24, 2013

Dependency Injection

Purpose

To implement a loosely coupled architecture in order to get better testable, maintainable and extendable code.

Examples

  • the Doctrine2 ORM uses dependency injection e.g. for Configuration that is injected into a Connection object. for testing purposes, one can easily create a mock object of the configuration and inject that into the connection object
  • Symfony and Zend Framework 2 already have containers for DI that create objects via a configuration array and inject them where needed (i.e. in Controllers)