How Xdebug Works

Before we set up Xdebug, I want to talk through how it works so the setup makes more sense and it doesn't seem like a series of strange steps.

Before we set up Xde­bug, I want to talk through how it works so the set­up makes more sense and it doesn’t seem like a series of strange steps. Plus, it’s impor­tant to under­stand, at least at a high lev­el, how the tools you use work. 

As I men­tioned in the last video, Xde­bug is a PHP exten­sion and runs on the local serv­er as part of PHP that runs your appli­ca­tion. Our web serv­er that runs the site via PHP would have Xde­bug installed and enabled in order for us to use.

When Xde­bug is run­ning, it will call back to your IDE (like Php­Storm or VS Code) from the serv­er where it’s run­ning. Your IDE will sit and lis­ten for that con­nec­tion on a spe­cif­ic port (typ­i­cal­ly port 9000 or 9003). 

You load a page in the brows­er for your project and when that hap­pens Xde­bug sends a con­nec­tion request to your IDE and says hey, I am get­ting a request, what do you have for me?”. At this point, Xde­bug and your IDE start com­mu­ni­cat­ing via the [[DBGP pro­to­col]]. This sounds fan­cy (and maybe it is) but it’s just a pro­to­col cre­ate by Xde­bug for com­munca­tion between itself and an IDE

Explana­to­ry chart I use in the video via the arti­cle Under­stand­ing XDe­bug using Mes­sage Sequence Charts (msc­gen)

Here are all of the videos in Debugging with Xdebug:

1What We'll Learn About DebuggingIn this course we'll learn that we can ditch var_dump() and dd() and move to a more powerful, faster, and easier way to debug problems in our code. 03:10
2What is Xdebug?Xdebug is, at its core, step debugger that has tight integration with IDEs to make it really simple to set breakpoints in PHP code to gain insight into what your code is doing during runtime. 02:08
3How Xdebug WorksBefore we set up Xdebug, I want to talk through how it works so the setup makes more sense and it doesn't seem like a series of strange steps. 06:41
4Installing the Buggy PluginWe install the Buggy plugin. We'll use this plugin to work through the course material and learn how to use Xdebug. 04:27
5Setting Up Xdebug with DDEV and PhpStormFor this video, we are going to learn how to set up Xdebug with PhpStorm running a local server on DDEV. Xdebug runs on the server, as a PHP extension, so the first thing we need to do is enable Xdebug in our Docker container that is managed by DDEV. 06:14
6Setting Up Xdebug with DDEV and VS CodeFor this video, we are going to learn how to set up Xdebug with VS Code running a local server on DDEV. 06:31
7Setting Up Xdebug with Nitro and PhpStormFor this video we are going to learn how to set up Xdebug with PhpStorm running a local server on Craft Nitro. 06:19
8Setting Up Xdebug with Nitro and VS CodeFor this video, we are going to learn how to set up Xdebug with VSCode running a local server on Nitro. 04:38
9Setting Up Xdebug with MAMP Pro and PhpStormHow to set up Xdebug with PhpStorm running a local server using MAMP Pro. 05:12
10Setting Up Xdebug with MAMP Pro and VS CodeA short tutorial on how to set up Xdebug with VSCode running a local server using MAMP Pro. 05:04
11What Can We Do With a Step Debugger?Before we start debugging the code in the Buggy plugin you installed in a previous video, let's review the concepts and terminology of working with a step debugger like Xdebug. 08:53
12Debugging with Xdebug in PhpStorm, Bug 1We learn how to use step debugging in PhpStorm to fix the first bug in the Buggy plugin. 10:53
13Debugging with Xdebug in PhpStorm, Bug 2Our bug hunting continues, as we discover yet another bug we need to fix using Xdebug in PhpStorm. 12:08
14Debugging with Xdebug and PhpStorm, Bug 3We use Xdebug in PhpStorm to find and fix the last bug in the Buggy plugin. Or is it?? 08:11
15Debugging with XDebug in VS Code, Bug 1We learn how to use step debugging in VS Code to fix the first bug in the Buggy plugin. 11:22
16Debugging with Xdebug in VS Code, Bug 2We discover yet another bug we need to fix using Xdebug in VS Code. 10:49
17Debugging with Xdebug in VS Code, Bug 3We use Xdebug in VS Code to find and fix the last bug in the Buggy plugin. Or is it?? 10:16
18Debugging Twig Templates with PhpStorm and XdebugPhpStorm supports debugging Twig templates with Xdebug. Set breakpoints and inspect the application runtime. 06:49
Course In-ProgressThis course is still being updated with new content. Check back for more!

Loading next video...