Dependency Injection in Drupal 8

Click here to watch Dependency Injection in Drupal 8.

Along with its embrace of OOP in general, Drupal 8 has embraced the Dependency Injection pattern in particular. While it's one of the simplest OO design patterns you'll ever come across, Dependency Injection has far-reaching consequences for how we structure and organize our code.

This talk will begin with an explanation of the pattern, discussing its value in a general programming context, and then narrow the focus to look at how we've been making use of DI in Drupal 8 core. The talk will also introduce you to D8's Dependency Injection Container, built on the Dependency Injection component from Symfony, and explain why you need to know about this as a module developer.

If you haven't looked at D8's codebase recently, you might be in for a bit of a shock and feel like you simply don't know where to start in getting up to speed with all the changes. This talk will offer an ideal starting point as it will touch on many of the most fundamental behind-the-scenes changes that anyone writing Drupal code needs to be aware of.

The following questions will be answered in this session:

  • What is Dependency Injection?
  • What problems does it solve?
  • What is a Dependency Injection Container?
  • Why is this relevant to me as a module maintainer?
  • What are these new "Bundles" that have nothing to do with entities?
  • What are compiler passes?
  • What are some best practices around Dependency Injection that I should be aware of?
Schedule info
Time slot: 
Tuesday, May 21 - 02:00pm-03:00pm
B 113 - NewMedia!
Session Info
Coding + Development
Experience level: 


This is a very very important topic for D8, about a topic that is very difficult to grasp without a solid walkthrough. Kat is well suited for the task, really looking forward to this one.

You will get smarter just by being in the same room as Katherine Bailey. Highly recommend.

I'd click 'add this to my calendar' if I could. :-)