# Debugging with Xdebug
Xdebug (opens new window) is an extension for PHP, and provides a range of features to improve the PHP development experience. The setup can depend on your local development environment and which IDE you are using.
# DDEV, Xdebug and VSCODE
Xdebug can have a signifant performance hit on PHP requests, so by default we usually run local development enviroments without Xdebug enabled.
- enable XDebug with DDEV, assuming a default DDEV Drupal configuration:
ddev xdebug
In VSCode, enable the PHP Debug extension (opens new window)
Click on the Run and Debug icon to set the configuration.
Cick 'create a launch.json file'
- Add the following to the launch.json file
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"log": true,
"pathMappings": {
"/var/www/html": "${workspaceRoot}/MY_PROJECT",
}
}
]
}
Note that the path mapping might depend on where you workspace root is. In this example, I have a workspace into which I have created the project into the MY_PROJECT folder. DDEV runs from within the MY_PROJECT folder, so it maps that folder to /var/www/html
- Press the Start Debugging icon to start listening for Xdebug
- Add a breakpoint to your index.php file by clicking to the left of the line numbers of a line with code on.
Load the home page of the site
See the script break and provide you with variables and callstack.