英文:
Xdebug not stopping at breakpoints
问题
Xdebug在断点处不停止。
我尝试了不同版本的Xdebug(当前版本为v1.32.1、v1.32.0、v1.31.1、v1.31.0、v1.30.0)。
这是我的launch.json
文件中的配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
是否可能与Web服务器冲突?
这是我的php.ini
文件中的配置(位于文件底部):
[xdebug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003 // 即使没有这一行也不起作用。
安装向导
从 <https://xdebug.org/wizard> 的摘要
• Xdebug已安装:3.2.1
• 服务器API:Apache 2.0处理程序
• Windows:是的
• 编译器:MS VS16
• 架构:x64
• Zend服务器:否
• PHP版本:8.2.4
• Zend API编号:420220829
• PHP API编号:20220829
• 调试构建:否
• 线程安全构建:是
• OPcache已加载:否
• 配置文件路径:无值
• 配置文件:C:\xampp\php\php.ini
• 扩展目录:C:\xampp\php\ext
我已从向导中下载了文件并正确重命名。
根据文档,端口9003是正确的。但我也尝试了端口9000。
如果我前往https://portchecker.co/checking并检查端口9000或9003,它们都是关闭的。
- 我重新安装了XAMPP
- 我重新安装了VS Code
我还前往设置 -> 功能 -> 调试 -> 允许处处断点
。
英文:
Xdebug does not stop at breakpoints.
I tried different versions of Xdebug. (current v1.32.1, v1.32.0, v1.31.1, v1.31.0, v1.30.0)
This is my configuration at the launch.json
file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]}
Could there be a conflict with the web server?
This is my configuration in the php.ini
(all the way at the bottom of the file):
[xdebug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003 // it also doesnt work without this line.
Installation Wizard
Summary from <https://xdebug.org/wizard>
• Xdebug installed: 3.2.1
• Server API: Apache 2.0 Handler
• Windows: yes
• Compiler: MS VS16
• Architecture: x64
• Zend Server: no
• PHP Version: 8.2.4
• Zend API nr: 420220829
• PHP API nr: 20220829
• Debug Build: no
• Thread Safe Build: yes
• OPcache Loaded: no
• Configuration File Path: no value
• Configuration File: C:\xampp\php\php.ini
• Extensions directory: C:\xampp\php\ext
I've downloaded the file from the wizard and renamed it correctly.
Port 9003 is correct according to the documentation. But I also tried port 9000 as well.
If I go to https://portchecker.co/checking and check for Port 9000 or 9003 they are closed.
- I reinstalled XAMPP
- I reinstalled VS Code
I also went to Settings -> Features -> Debug -> Allow Breakpoints Everywhere
.
答案1
得分: 2
我已经安装了xampp和xdebug。
我们的launch.json文件和向导输出是相同的,似乎对我来说可以工作。
我的php.ini
文件没有包含最后一行的端口号,也没有包含你所拥有的xdebug闭合括号后的撇号。
[xDebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes
考虑到已经为您映射了扩展目录,您不应该需要整个文件路径来定义您的zend_extension。
我建议您再次检查您在vscode设置中是否定义了"php.debug.executablePath"
。
在运行vscode中的Listen for Xdebug
后,我的设置如下:
- 运行
Listen for Xdebug
在 vscode 中 - 在浏览器中导航到我在这里使用的文件
http://localhost/info/index.php
如果进行这些更改后仍然不起作用,也许可以再次确认断点是否真的可以到达。
英文:
I went ahead and installed xampp and xdebug.
Our launch.json files and wizard output are identical and it seems to work ok for me.
My php.ini
doesn't include the last line with the port number or the apostrophe after the xdebug closing brace that you have.
[xDebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes
You shouldn't need the entire file path for your zend_extension considering that the extensions directory is already mapped for you.
I would double check that you've defined your "php.debug.executablePath":
in vscode settings as well.
Here's what mine looks like after
- Running
Listen for Xdebug
in vscode - Navigating to the file I used here at
http://localhost/info/index.php
in the browser
If making those changes still doesn't work, maybe double check that the breakpoint is actually reachable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论