Dependency Injection Container
From phpBB Development Wiki
What is it?
A dependency injection container is an object that manages services and their creation. A service is an object that does something; it provides a service. Services can depend on other services, and the container has the job of wiring them up.
You can think of the container as "an array of objects on steroids". It knows about a number of objects and allows you to retrieve them. It will only create the objects you ask for, so it is lazy in a sense.
phpBB uses the Symfony2 Dependency Injection component.
In order to create them, the container needs to know about how services should be created. You do that by configuring it. phpBB uses a YAML configuration format to do this. All configuration files are within the config directory.
The entry point is services.yml. It imports some other files and then defines the top level services. Modifications to phpBB's core will likely involve changes to one of the service configuration files.
phpBB extensions are also able to define services. This is important if they want to provide cron tasks or any other service. By creating a config/services.yml file within the extension directory, that file will automatically get loaded into the container.
The container allows attaching tags to services. These tags are used to get a collection of certain types of services and then using that collection. The following tags are currently supported:
- cron.task: Cron task, which is automatically executed when it is ready to be run.
For further reading, check out the following resources: