In PHP, we have functions like var_dump(), dump() and dd() that are used to debug code and print output to the screen.
In Drupal, we have functions like dpm() and kint(), too.
These functions are great for simple debugging but sometimes I need more, which is when I reach for a step debugger - namely, Xdebug.
This is common when working in complex legacy code, where you need to be able to see a breakpoint and step through the code to see what path it takes and what the state is at each step.
Enter Xdebug
Xdebug is a tool I use fairly often and something I have configured on an individual project basis.
This week, I spent some time adding it to a new project and ensured my notes and documentation still worked.
I use Docker and Docker Compose on Linux, so there are slight changes compared to running PHP natively, so I wanted to make sure it still works.
If you use Docker Compose on Linux, it may be useful for you.
If you haven't tried Xdebug before, I suggest giving it a try and see if improves your debugging.
- Oliver
Was this interesting?
About me
I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.