mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-21 12:52:01 +02:00
First draft - Resolves #280
This commit is contained in:
committed by
Josh Lockhart
parent
009ce6b18b
commit
5e0f12004c
14
_posts/06-04-01-Containers.md
Normal file
14
_posts/06-04-01-Containers.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
isChild: true
|
||||
---
|
||||
|
||||
## Containers {#containers_title}
|
||||
|
||||
The first thing you should understand about Dependency Injection Containers is that they are not the same thing as Dependency
|
||||
Injection. A container is a convenience utility that helps us implement Dependency Injection, however, they can be and often
|
||||
are misused to implement an anti pattern, Service Location. Using a container as a Service Locator within your classes arguably
|
||||
creates a harder dependency on the container than the dependency you are replacing. It also makes your code much less transparent
|
||||
and ultimately harder to test.
|
||||
|
||||
Most modern frameworks have their own Dependency Injection Container that allows you to wire your dependencies together through configuration.
|
||||
What this means in practice is that you can write application code that is as clean and de-coupled as the framework it is built on.
|
Reference in New Issue
Block a user