php 远程调试不会在断点处停止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2359712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remote debugging won't stop at breakpoints
提问by Bryan M.
I'm having a problem with xdebug not stopping at breakpoints when using remote debugging (everything is fine when running scripts via the command line). It will break at the first line of the program, then exit, not catching any breakpoints.
我在使用远程调试时遇到了 xdebug 没有在断点处停止的问题(通过命令行运行脚本时一切正常)。它将在程序的第一行中断,然后退出,不捕获任何断点。
It used to work fine, until I switched over to using MacPorts for Apache and PHP. I've tried re-compiling it several times (with several versions), but no dice.
它曾经工作得很好,直到我改用 MacPorts for Apache 和 PHP。我试过多次重新编译它(有几个版本),但没有骰子。
I'm using PHP 5.3.1 and Xdebug 2.1.0-beta3
我正在使用 PHP 5.3.1 和 Xdebug 2.1.0-beta3
I've also tried at least 3 different debugging programs (MacGDBp, Netbeans and JetBrains Web IDE).
我还尝试了至少 3 种不同的调试程序(MacGDBp、Netbeans 和 JetBrains Web IDE)。
My php.ini settings look like:
我的 php.ini 设置如下所示:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=localhost
xdebug.idekey=webide
And when I log the debugger output, setting a breakpoint looks like this/;
当我记录调试器输出时,设置断点如下所示/;
<- breakpoint_set -i 895 -t line -f file:///Users/WM_imac/Sites/wm/debug_test.php -n 13 -s enabled
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="895" state="enabled" id="890660002"></response>
<- breakpoint_set -i 895 -t line -f file:///Users/WM_imac/Sites/wm/debug_test.php -n 13 -s enabled
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="895" state="enabled" id="890660002"></response>
When run, the debugger will get the context of the first line of the application, then send the detach and stop messages.
运行时,调试器将获取应用程序第一行的上下文,然后发送分离和停止消息。
However, this line is output when starting the debugger.
但是,该行是在启动调试器时输出的。
<- feature_get -i 885 -n breakpoint_types
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="885" feature_name="breakpoint_types" supported="1"><![CDATA[line conditional call return exception]]></response>
<- feature_get -i 885 -n breakpoint_types
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="885" feature_name="breakpoint_types" supported="1"><![CDATA[line conditional call return exception]]></response>
Does 'line conditional call return exception' mean anything?
“线路条件调用返回异常”有什么意义吗?
回答by pitchandtone
I had this problem and took me ages to find the answer.
我遇到了这个问题,花了很长时间才找到答案。
In your debug config, in the server area, click Configure, go to Path Mapping, click the path that's there and click edit, change to Path in file system and navigate to the correct file.
在您的调试配置中,在服务器区域中,单击配置,转到路径映射,单击那里的路径并单击编辑,更改为文件系统中的路径并导航到正确的文件。
Done.
完毕。
回答by Matthias
I had the same problem, and finally I found that my php.ini was missing these two important settings:
我也遇到了同样的问题,最后发现我的php.ini缺少这两个重要的设置:
xdebug.remote_autostart = "On"
xdebug.remote_enable = "On"
Then it worked perfectly.
然后它完美地工作。
回答by axel_c
XDebug works fine in my Ubuntu Lucid box using NetBeans, and i do have the zend_extension line in my php.ini (/etc/php5/apache2/php.ini).
XDebug 在我使用 NetBeans 的 Ubuntu Lucid 框中运行良好,而且我的 php.ini (/etc/php5/apache2/php.ini) 中有 zend_extension 行。
I'm using netbeans 6.9 and PHP 5.2 with xdebug 2.0.4-2
我将 netbeans 6.9 和 PHP 5.2 与 xdebug 2.0.4-2 一起使用
I'm pasting the relevant lines here, hope it helps:
我在这里粘贴相关的行,希望它有帮助:
zend_extension=/usr/lib/php5/20060613/xdebug.so
[debug]
; Remote settings
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=1
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=
; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32
; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32
回答by mfit
from http://xdebug.org/docs/install, "You should ignore any prompts to add "extension=xdebug.so" to php.ini — this will cause problems."
来自http://xdebug.org/docs/install,“您应该忽略任何将“extension=xdebug.so”添加到 php.ini 的提示——这会导致问题。
so, this fixed it for me :
所以,这为我修好了:
in the config file , where you load the xdebug extension ( for me , for the CLI version of php , that was /etc/php5/cli/conf.d/xdebug.ini ) - dont specify
在配置文件中加载 xdebug 扩展(对我来说,对于 CLI 版本的 php,即 /etc/php5/cli/conf.d/xdebug.ini) - 不要指定
extension=xdebug.so
扩展=xdebug.so
instead , use
相反,使用
zend_extension=/path/to/xdebug/module/xdebug.so
zend_extension=/path/to/xdebug/module/xdebug.so
( for me , this was something like /usr/lib/php5/(...)/xdebug.so )
(对我来说,这就像 /usr/lib/php5/(...)/xdebug.so )
Use locate xdebug.soto find the location.
使用locate xdebug.so找到位置。
回答by safl
I have had the same issue, the solution for me was to have the local code on the same path as the remote code.
我遇到了同样的问题,我的解决方案是将本地代码与远程代码放在同一路径上。
Example
例子
On the webserver the code was located on the path: /var/www/dev01/app_name
在网络服务器上,代码位于路径上: /var/www/dev01/app_name
Locally the code was located in my home directory: /home/me/projects/app_name
本地代码位于我的主目录中: /home/me/projects/app_name
This configuration caused my IDE (Eclipse and Komodo) to fly straight past the breakpoints.
这种配置导致我的 IDE(Eclipse 和 Komodo)直接飞过断点。
Changing the local path from /home/me/projects/app_nameto /var/www/dev01/app_namefixed the issue.
Using sshfs to locally mount the remote filesystem makes it even easier.
将本地路径从 更改/home/me/projects/app_name为/var/www/dev01/app_name解决了问题。使用 sshfs 在本地挂载远程文件系统更容易。
回答by Aaron Bridges
I just experienced something similar to safl's comment above using Komodo but not sure if it's related:
我刚刚使用 Komodo 经历了类似于上面 safl 评论的事情,但不确定它是否相关:
I had xdebug set up using zend_extension with Komodo and it works perfectly, can set breakpoints and xdebug_break(), but only some files. Others did not work.
我使用带有 Komodo 的 zend_extension 设置了 xdebug,它工作得很好,可以设置断点和 xdebug_break(),但只有一些文件。其他人没有工作。
The solution was in the way that the mapping of the remote and local paths occurred. Turns out that Komodo is doing a case-sensitive compare on path name, so my mapping didn't quite match. Files that the debugger opened from stepping through were on the right path, but files that I opened through the ide had an uppercase driveletter which apparently caused Komodo to overlook.
解决方案是远程和本地路径的映射发生的方式。事实证明,科莫多正在对路径名进行区分大小写的比较,所以我的映射并不完全匹配。调试器逐步打开的文件在正确的路径上,但我通过 ide 打开的文件有一个大写的驱动器字母,这显然导致 Komodo 被忽略。
回答by Mike S.
I tried all these solutions to no avail. I was confused because XDebug worked for one of my projects but not this new one. After stumbling around comparing configuration properties, I realized that on
我尝试了所有这些解决方案都无济于事。我很困惑,因为 XDebug 适用于我的一个项目,但不适用于这个新项目。在比较配置属性后,我发现
Project Properties > Sources > Web root:
项目属性 > 源 > Web 根:
the value was set to a default valueon the new project, but set to webrooton the existing project. So, I browsed to the project's webroot and set that value. I tested it and, bada-bing, it worked.
该值default value在新项目上设置为 a ,但webroot在现有项目上设置为。因此,我浏览到项目的 webroot 并设置该值。我测试了它,bada-bing,它起作用了。


回答by Joerg
I use Eclipse and also looked for a while. All things in php.inihave been right.
我使用 Eclipse,也找了一段时间。里面的一切php.ini都是对的。
At the end, I found out, that in Eclipsethe debugger was set so ZEND-Debugger. After I changed it to XDEBUGit worked fine.
最后,我发现,在 Eclipse 中,调试器设置为ZEND-Debugger. 我把它改成后,XDEBUG它工作得很好。
Regards Joerg
问候约尔格
回答by q0rban
I ran into this same exact thing and was banging my head against it for a while. At some point I had also added ZendDebugger.so to my PHP.ini and that was what was breaking Xdebug. Commenting out the ZendDebugger.so line in my php.ini fixed it.
我遇到了同样的事情,并用我的头撞了一会儿。在某些时候,我还将 ZendDebugger.so 添加到我的 PHP.ini 中,这就是破坏 Xdebug 的原因。注释掉我的 php.ini 中的 ZendDebugger.so 行修复了它。
If you're not using ZendDebugger, you might just start disabling other Zend extensions and see if it's another extension causing the conflict.
如果您没有使用 ZendDebugger,您可能只是开始禁用其他 Zend 扩展,看看是否是另一个导致冲突的扩展。
回答by mjs
Are you totally sure you're not loading the Xdebug via extension=xdebug.so? Xdebug will load if this line appears in your php.ini(i.e. it appears in phpinfo()output, etc.) but breakpoints do not work if loaded in this way. (It will even connect to debugger clients, and accept breakpoints--they just never get triggered.)
您确定没有通过 加载 Xdebugextension=xdebug.so吗?如果此行出现在您的php.ini(即它出现在phpinfo()输出等中),则 Xdebug 将加载,但如果以这种方式加载,断点将不起作用。(它甚至会连接到调试器客户端,并接受断点——它们永远不会被触发。)
I suggest you comment out the zend_extensionline and see if it's still loaded--you might think you're loading Xdebug via /etc/php5/conf.d/xdebug.ini, for example, but something has added it to /etc/php5/apache2/php.inibehind your back.
我建议您注释掉该zend_extension行并查看它是否仍然加载——/etc/php5/conf.d/xdebug.ini例如,您可能认为您正在通过 加载 Xdebug ,但是某些东西已将它添加到/etc/php5/apache2/php.ini您的背后。
See this question & answerfor more information.
有关更多信息,请参阅此问答。

