For this video, we are going to learn how to set up Xdebug with VS Code running a local server on DDEV.
For this video, we are going to learn how to set up Xdebug with VS Code 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.
Fortunately, DDEV already has support for this and a command we can to toggle Xdebug on and off. This is how we can set whether we are in debug mode or not.
$ ddev xdebug enable
This enables Xdebug so it is running as a PHP extension. Now it will be available to call back to our IDE on port 9003 when it receives a HTTP request.
The launch.json
configuration file for DDEV and VS Code:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"hostname": "yourhostname.ddev.site",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceRoot}"
}
}
]
}
Debugging with Xdebug is made up of the following videos: