Chapter 9: Dependency Injection Example
In this chapter, we are going to look at a very popular pattern in modern PHP – the dependency injection (DI) container. This is a system that acts as a global application-level factory and combines configuration and instance management.
You could have a read through Fabien Potencier's article from way back in 2009, which tried to educate the PHP masses about what a DI container is and why we should be using one:
http://fabien.potencier.org/do-you-need-a-dependency-injection-container.html.
Bear in mind that this is a vintage article, but the basic points are all there, and it is worth a read through. It's also an interesting bit of PHP history.
We're going to learn all about what a DI container does ...
Get The Art of Modern PHP 8 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.