Xdebug from anywhere
With the following launch.json file, you can use PHP breakpoints without having to load a WordPress site from the public folder. Just make sure to add the file to the .gitignore so other devs don’t run into conflicts! Copy the below and update the following keys to use xdebug.
For example, your keys for a plugin might be:
- ${user}
1030903 - ${local-site-dir}:
judicials - ${rest-of-path}:
plugins/cno-plugin-pdf-download-block
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug 3.0 (Local)",
"type": "php",
"request": "launch",
"port": 9003,
"xdebugSettings": {
"max_children": 128,
"max_data": 1024,
"max_depth": 3,
"show_hidden": 1
},
"pathMappings": {
"/Users/${user}/Local Sites/${local-site-dir}/app/public/wp-content/${rest-of-path}": "${workspaceFolder}"
}
},
{
"name": "Listen for Xdebug (Local)",
"type": "php",
"request": "launch",
"port": 9000,
"xdebugSettings": {
"max_children": 128,
"max_data": 1024,
"max_depth": 3,
"show_hidden": 1
},
"pathMappings": {
"/Users/${user}/Local Sites/${local-site-dir}/app/public/wp-content/${rest-of-path}": "${workspaceFolder}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"xdebugSettings": {
"max_children": 128,
"max_data": 1024,
"max_depth": 3,
"show_hidden": 1
}
}
]
}