What is dependency injection container in PHP?

To better understand dependency injection container, the dependency injection design pattern is a prerequisite.

Dependency injection container is very useful and recommended way of managing class dependencies. It is a utility which helps you to implement the dependency injection pattern in your application.

Dependency injection container is a combination of container design pattern, factory pattern and (optionally) flyweight pattern when utilizing objects as service descriptors. General implementations of dependency injection container are also inspecting components (utilizing reflection).

See also

Found a typo? Something wrong with this content?

Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all contributors.