Services and Containers in Drupal 8

Author: Jennifer Hodgdon
Date Written: 20 October, 2014
Type: Presentation
Subject: Drupal

On October 18, 2014, I gave at talk at the Pacific Northwest Drupal Summit entitled "Services, Dependency Injection, and Containers, oh my!". Description:

Drupal 8 introduces the concepts of Services, Dependency Injection, and the Container to Drupal. They my seem a bit mysterious to programmers who are used to working with Drupal 7 or earlier versions. To help clear up the mysteries, this session will answer these questions:

  • What is a service?
  • What are those $container variables all over the code?
  • What are dependencies, and what is injection?
  • What's the easiest way to interact with services, and ... since you're about to tell me how wrong it is to do it that way, how should I really be doing it in my code?
  • How can I override a service?
  • Why is this all important (why did Drupal adopt this conceptual framework in the first place)?

Slides are attached below.