【发布时间】:2021-06-29 04:35:48
【问题描述】:
我有一个初学者问题。我正在努力让 Xdebug 在 Visual Studio Code 中为 PHP 运行。我尝试了很多,但似乎没有任何效果。 VSCode 不会在我的断点处停止。以下是我已经尝试或设置的列表:
- 我在 XAMPP 中从 Apache 服务器编辑了 PHP.ini。如您所见,我已经添加了 dll:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.idekey="vscode"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.remote_port = "8066"
zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
- 确保 Apache 服务器监听 8066 端口。
- 在 Visual Studio Code 中,我安装了 PHP 调试和其他 PHP 智能工具
- VSCcode中的launch.json如下:
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 8066,
"runtimeExecutable": "C:/xampp/php/php.exe"
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 8066,
"runtimeExecutable": "C:/xampp/php/php.exe"
- 我还在 VSCode 中将 php.exe 设置为标准:
我做错了什么?我敢打赌这是非常愚蠢的事情。希望大家多多指教。
【问题讨论】:
-
我建议你找一些带有屏幕截图的指南并按照它。你可以从这里开始:learnxdebug.com
-
我会尝试再读一遍。我将搜索版本 3。我想我在没有注意到的情况下阅读了很多不同的版本。我是一位经验丰富的程序员,但从未尝试过 php。这对我来说有点新鲜。感谢您的回复。
-
查看您当前的 Xdebug 配置:1) 您混合了 Xdebug v2 和 v3 参数。仅转换为 v3 参数并清理它们。 2) Xdebug v3 默认使用
client_port = 9003.. 因此将VSCode 中的端口(@987654327@ 行)更改为9003 可能会完成这项工作(它必须是VSCode 监听的Xdebug 端口——它是连接到VSCode 的Xdebug 和不是其他方式:一个非常常见的错误/误解)。
标签: php visual-studio-code installation xampp xdebug