Debugging 101: Stop Time & Fix Your Code with VSCode

Presenter: cotterpinx
Co-Presenter(s):
n/a

You’ve written the code. It’s running and you’re not seeing any errors, but somehow you’re not getting the output you expected. Something’s happening in there, but what? If only you could freeze time and look under the hood... With debugging tools, you can!

Visual Studio Code (VSCode) is one of the most popular free & open source code editors currently available. Contributions from the PHP coding community have produced several extremely useful add-ons, resulting in a powerful (free!) coding environment complete with built-in debugging support. It can be a little tricky to set up, however, and if you haven’t used a debugger before the features and terminology can be a little overwhelming. 

We can help!

We’ll start with a walkthrough of the steps to get PHP debugging enabled in VSCode for an instance of  DrupalVM using the Chrome browser, and highlight potential gotchas in your setup.

Once we have everything up and running, we’ll explain common debugging features and how they can help you, including:

  • Setting breakpoints
  • Special breakpoint types: Function, Conditional
  • Stepping through your code (step into/step out/step over)
  • Examining the Variables & the Call Stack
  • Using the Debug Console REPL 

You’ll leave with an understanding of what it takes to get PHP debugging up and running in VSCode, and what debugging tools can do for you.
 

Audience
Experience Level
Beginner
Session Track