复制 phpinfo信息到 https://xdebug.org/wizard ,根据结果下载xdebug
将下载好的dll扩展放到php的ext目录下并重命名xdebug.dll
打开php.ini配置文件在最下面增加
[XDebug]
zend_extension = xdebug
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.port=9003
打开vscode 添加插件php debug
配置xdebug的环境
{
"version":"0.2.0",
"configurations": [
{
"name": "Launch current script in console",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"externalConsole": false,
"port": 9003
},
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
配置vscode
增加
{
"security.workspace.trust.untrustedFiles": "open",
"editor.multiCursorLimit": 20000,
"extensions.ignoreRecommendations": true,
"tabnine.experimentalAutoImports": true,
"go.alternateTools": {},
"workbench.editorAssociations": {
"*.cap": "default"
},
"diffEditor.ignoreTrimWhitespace": false,
"settingsSync.ignoredExtensions": [],
"php.debug.executablePath": "C:\\phpstudy_pro\\Extensions\\php\\php8.0.30nts\\php.exe",
"php.validate.executablePath": "C:\\phpstudy_pro\\Extensions\\php\\php8.0.30nts\\php.exe",
"explorer.confirmDelete": false
}
重启vscode后,任意位置打断点
点击启动按钮
控制台中可看到监听中
在浏览器中访问该地址
在vscode中即可看到对应调试信息