Debugging in Drupal 8

Featured speaker

Session slides

 

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 I start from? Drupal 8's bootstrapping 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 find a bug, we use a debugging technique to understand it, and then 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 Drush / Console scripts.
  • Debugging test runs.
  • Debugging services with PsySH.

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 tips on how to find bugs and understand concepts by debugging code.

Drupal level: Intermediate, Language: English


About JuampyNR

Organization: Lullabot

Twitter | Linkedin

Juampy started working as a web developer in 2006 after finishing his Computer Engineering & Information Systems degree in London. After spending a few years developing in Ruby on Rails and Symfony, Juampy discovered Drupal. Drawn by the Drupal community and the "mind-blowing effect of getting a project done 10 times faster than before", Juampy has never looked back.

Since then, he's become more and more involved in the issue queues, which led in turn to becoming maintainer of Twitter, OAuth and Devel modules, among others. He also organizes events, giving sessions at national and international conferences, and wrote the Drush User's Guide and Drush for Developers. He feels privileged to be able to experiment, have fun and be challenged everyday. Before joining Lullabot, Juampy worked for digital companies in the UK, Bolivia, Spain and the United States for clients such as the BBC, Reuters and the Spanish Gas Natural Fenosa. Juampy lives in Madrid, Spain. He enjoys spending his free time with relatives and friends, playing squash, roller skating, golfing and reading books. He is known as juampynr at Drupal.org and IRC.