復制 phpinfo信息到 https://xdebug.org/wizard ,根據(jù)結(jié)果下載xdebug

image.png
將下載好的dll擴展放到php的ext目錄下并重命名xdebug.dll

image.png
打開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

image.png
配置xdebug的環(huán)境

image.png
{
"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

image.png
增加

image.png
{
"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后,任意位置打斷點

image.png
點擊啟動按鈕

image.png
控制臺中可看到監(jiān)聽中

image.png
在瀏覽器中訪問該地址
在vscode中即可看到對應(yīng)調(diào)試信息

image.png