Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Dependency Injection
Feb 25, 2016 @ 10:43:57

Loïc Faugeron has posted another of his "Ultimate Developer Guide" series to his site, this time with a focus on the dependency injection component of the Symfony framework.

In this guide we explore the standalone libraries (also known as "Components") provided by Symfony to help us build applications. We've already seen: HTTP Kernel and HTTP Foundation, event dispatcher, routing and YAML. We're now about to check Dependency Injection, and finally in the next article we'll have a look at Console.

He starts with an introduction to the dependency injection pattern by refactoring a request to an API for its status out into classes with different responsibilities. He includes both the code he started with and what he's refactoring to. He thing brings in the Dependency Injection component, shows how to register the different classes and define a YAML configuration with their relationships. He also includes an examples of how to pass in parameters when injecting services, extending the functionality and compile the functionality into static values.

tagged: ultimate developer guide symfony dependency injection tutorial series

Link: https://gnugat.github.io/2016/02/24/ultimate-symfony-dependency-injection.html