One of the first things that I found out when I started working with Drupal 8 is that: since the code is object oriented, it flows through a higher number of files than in Drupal 7. Therefore, debugging a piece of logic by using prints, dpms, dds and such becomes inefficient. Instead, we need to embrace and master the debugger; not only to find bugs but also to understand Drupal's APIs. My trust in the debugger is so strong that I think that developers who don’t learn how to use the debugger won’t last long in Drupal 8.

After installing the debugger, the first challenge is: where should we start? Drupal 8's bootstrap process can be daunting: it makes dozens of callbacks before the actual request handler that we are looking for gets called. This can be frustrating for beginners, but I discovered that it is a learning process that pays dividends. In this session I will show a few clips of real life examples where we discover an issue, we use a debugging technique to find it and understand it, and finally we fix it.

Here are some of the topics that we will see:

  • Adjusting the debugger so it listens for all requests and waits for the first breakpoint.
  • Setting a breakpoint on a line that throws an error and working our way up the backtrace.
  • Debugging unexpected behavior that does not throw an error.
  • Debugging code that runs when Drupal is rebuilding structures.
  • Navigating through parent classes, traits and interfaces.
  • Extracting the failing logic into a script for a faster debugging.
  • Monitoring loops until they hit a condition.
  • Debugging test runs.

Back end developers with some experience working on Drupal 7 projects and looking forward to work with Drupal 8 will leave the session with a few ideas on how to find bugs and understand concepts by debugging code.

I have already started recording the clips that I will use on my session. They are at my YouTube channel.

Note: I use VIM + VDebug for coding. If you use a different IDE such as Sublime or PHPStorm, this talk will still be useful to you as the concepts that I will cover are the same for all Debuggers.

View the slides here

Drupal level: 
Intermediate
Speakers: 
Language: 
English

Patrocinadores Oro

Patrocinadores Plata

Colaboradores