c:\xampp
中安装XAMPP v3.2.4 x64并设置环境变量路径phpinfo()
中的所有文本并按照https://xdebug.org/wizard下载dll文件并复制到c:\xampp\php\ext
并在 zend_extension=path
末尾添加文本 php.ini
并检查 phpinfo()
页面和 xdebug 添加到此[XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1
在 php.ini 中htdocs
测试名称中创建项目并在 test.php
输入文本到
test.php
并在行中设置断点
为 PHP 创建自动
launch.json
开始调试
启动 chrome 和 url:
localhost/test/test.php
但是当刷新页面断点不起作用并且不停止代码时。
只需检查监听端口即可
[XDebug]
zend_extension=C:\xampp\php\ext\php_xdebug-3.0.1-7.2-vc15-x86_64.dll
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.mode=debug
xdebug.idekey=VSCODE
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
我遇到了这个问题,最终通过以下步骤解决了。
首先检查 VSCode 是否能够通过 log=true
第二个也是最重要的一个与pathMappings相关,它将远程代码映射到本地代码
听到的是我的 VSCode 调试配置
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"log": true,
"pathMappings": { "/var/www/html": "${workspaceRoot}"
最后配置你的xdebug.ini(你也可以把它们放在php.ini中)
zend_extension=zend_extension=C:\xampp\php\ext\php_xdebug-3.0.1-7.2-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9001
# Very Import !! remote_connect_back should be turned off
xdebug.remote_connect_back= 0
xdebug.remote_host=172.17.0.X
xdebug.remote_log=/tmp/xdebug.log
(这些配置与xdebug 2.9.X相关)