A dependency injection container is an object that knows how to auto-wire classes together. The auto-wire term implies both instantiating and properly configuring objects. This is by no means an easy task, which is why there are several libraries addressing this functionality.
The DependencyInjection component provided by the Symfony framework is a neat dependency injection container that can be easily installed by Composer.
Moving forward, let's go ahead and create a di-container directory where we will execute these commands and set up our project:
composer require symfony/dependency-injection
The resulting output suggests we should install some additional packages:
We need to make sure we add the symfony/yaml and symfony/config packages by running the following console...