Skip to Content
The Art of Modern PHP 8
book

The Art of Modern PHP 8

by Joseph Edmonds
October 2021
Intermediate to advanced content levelIntermediate to advanced
420 pages
7h
English
Packt Publishing
Content preview from The Art of Modern PHP 8

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern PHP

Modern PHP

Josh Lockhart
The PHP Workshop

The PHP Workshop

Alexandru Busuioc, David Carr, Markus Gray, Vijay Joshi, Mark McCollum, Bart McLeod, M A Hossain Tonu
PHP 8 Basics: For Programming and Web Development

PHP 8 Basics: For Programming and Web Development

Gunnard Engebreth, Satej Kumar Sahu

Publisher Resources

ISBN: 9781800566156Supplemental Content