XAMPP 1.7.3、Eclipse PDT 和XDebug - 在 Eclipse 中调试 PHP 网页永远不会在断点处停止
我的开发 Web 服务器当前是本地主机 (Win XP) 上的 XAMPP 1.7.3。
我刚刚使用 XDebug 设置了 Eclipse 3.6 PDT。 如果我将文件调试为“PHP 脚本”,它工作得很好,但是当将其调试为“PHP 网页”时,XDebug 会完全忽略断点。
只有在代码中手动插入 xdebug_break() 才会停止调试器。如果您想使用带有 Eclipse 断点的条件,这不是很有用。
这是我的配置:
php.ini:
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_idekey="ECLIPSE_DBGP"
phpinfo()
Zend Engine v2.3.0, Copyright (c)
1998-2009 Zend Technologies
with Xdebug v2.0.6-dev, Copyright (c) 2002-2009, by Derick Rethans
...
xdebug xdebug support enabled Version
2.0.6-dev
Supported protocols Revision DBGp -
Common DeBuGger Protocol $Revision:
1.125.2.7 $ GDB - GNU Debugger protocol $Revision: 1.87.2.1 $ PHP3 -
PHP 3 Debugger protocol $Revision:
1.22 $
Directive Local Value Master Value
xdebug.auto_trace Off Off
xdebug.collect_includes On On
xdebug.collect_params 0 0
xdebug.collect_return Off Off
xdebug.collect_vars Off Off
xdebug.default_enable On On
xdebug.dump.COOKIE no value no value
xdebug.dump.ENV no value no value
xdebug.dump.FILES no value no value
xdebug.dump.GET no value no value
xdebug.dump.POST no value no value
xdebug.dump.REQUEST no value no value
xdebug.dump.SERVER no value no value
xdebug.dump.SESSION no value no value
xdebug.dump_globals On On
xdebug.dump_once On On
xdebug.dump_undefined Off Off
xdebug.extended_info On On
xdebug.idekey no value no value
xdebug.max_nesting_level 100 100
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable Off Off
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_output_dir C:\xampp\tmp C:\xampp\tmp
xdebug.profiler_output_name xdebug_profile.%p xdebug_profile.%p
xdebug.remote_autostart On On
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host localhost localhost
xdebug.remote_log no value no value
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.show_exception_trace Off Off
xdebug.show_local_vars Off Off
xdebug.show_mem_delta Off Off
xdebug.trace_format 0 0
xdebug.trace_options 0 0
xdebug.trace_output_dir C:\xampp\tmp C:\xampp\tmp
xdebug.trace_output_name trace.%c trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3
有谁知道我做错了什么?
提前致谢!
My development web server is currently a XAMPP 1.7.3 on my localhost (Win XP).
I just set up my Eclipse 3.6 PDT with XDebug.
It works fine, if I debug a file as a "PHP script", but when it comes to debugging it as a "PHP web page", XDebug ignores the breakpoints completely.
Only a manually inserted xdebug_break() inside the code stops the debugger. This isn't very useful, if you want to use conditions with Eclipse's breakpoints.
Here my config:
php.ini:
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_idekey="ECLIPSE_DBGP"
phpinfo()
Zend Engine v2.3.0, Copyright (c)
1998-2009 Zend Technologies
with Xdebug v2.0.6-dev, Copyright (c) 2002-2009, by Derick Rethans
...
xdebug xdebug support enabled Version
2.0.6-dev
Supported protocols Revision DBGp -
Common DeBuGger Protocol $Revision:
1.125.2.7 $ GDB - GNU Debugger protocol $Revision: 1.87.2.1 $ PHP3 -
PHP 3 Debugger protocol $Revision:
1.22 $
Directive Local Value Master Value
xdebug.auto_trace Off Off
xdebug.collect_includes On On
xdebug.collect_params 0 0
xdebug.collect_return Off Off
xdebug.collect_vars Off Off
xdebug.default_enable On On
xdebug.dump.COOKIE no value no value
xdebug.dump.ENV no value no value
xdebug.dump.FILES no value no value
xdebug.dump.GET no value no value
xdebug.dump.POST no value no value
xdebug.dump.REQUEST no value no value
xdebug.dump.SERVER no value no value
xdebug.dump.SESSION no value no value
xdebug.dump_globals On On
xdebug.dump_once On On
xdebug.dump_undefined Off Off
xdebug.extended_info On On
xdebug.idekey no value no value
xdebug.max_nesting_level 100 100
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable Off Off
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_output_dir C:\xampp\tmp C:\xampp\tmp
xdebug.profiler_output_name xdebug_profile.%p xdebug_profile.%p
xdebug.remote_autostart On On
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host localhost localhost
xdebug.remote_log no value no value
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.show_exception_trace Off Off
xdebug.show_local_vars Off Off
xdebug.show_mem_delta Off Off
xdebug.trace_format 0 0
xdebug.trace_options 0 0
xdebug.trace_output_dir C:\xampp\tmp C:\xampp\tmp
xdebug.trace_output_name trace.%c trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3
Does anyone know what I'm doing wrong?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Eclipse 中的路径映射设置错误是问题所在。
附加信息:
始终使用 www.xdebug.org 上的最新版本的 XDebug,XAMPP (2.0.6) 中的版本存在一些错误,其中变量
。这个问题在当前的 2.1.0 版本中得到了解决。Wrong set path mappings in Eclipse were the problem.
Additional info:
Always use the latest version of XDebug from www.xdebug.org, the version in XAMPP (2.0.6) has some bugs where variables were
<Uninitialized>
. This got resolved in the current 2.1.0 release.这“可能”对一些在 eclipse 配置下调试 php 时遇到困难的人有帮助
:
- 虚拟盒子上的Win7专业版
- Eclipse Luna luna 服务版本 2 (4.4.2),PDT 插件安装在 c: 上
- wamp 2.5 (php 5.5.12, apache 2.4.9)
在桌面上:
单击 Windows 状态栏 wamp 图标(在 eclipse 之外,桌面右侧下方)
单击 PHP>; PHP 设置
勾选Xdebug远程调试/分析器/分析器启用触发器,直到它出现勾选(需要尝试几次才能工作,可能会出现错误但忽略它们)
单击 PHP>; PHP.ini
!!!警告!!!!
这最后一步实际上正在改变 c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini 不是 c:/wamp/www/bin/php/php5.5.12/php.ini 而是它仍然按照前面所述工作
在 eclipse 中:
Window>Preferences>PHP>PHP Executable
Window>Preferences>PHP>Debug
窗口 > 首选项 > PHP > 调试 > 安装的调试器
窗口 > 首选项 > PHP > 服务器
选择要调试的 php 文件,然后运行 > 调试 > 调试配置
最后在同一窗口中单击“调试”按钮,它应该可以工作(至少在我的机器上,经过一天的环顾后,这还不算太糟糕)
注意:也可以在左侧 Eclipse 资源管理器框架上选择文件 >运行>调试>调试配置和先前创建的 mydebugconfig)
供您参考文件 c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini 结尾
和文件 c:/wamp/www/bin/apache/apache2 结尾.4.9/bin/php.ini
This "could" be of help for some people who are struggling with debugging in php under eclipse
Config:
- Win7 pro on virtual box
- Eclipse Luna luna service release 2 (4.4.2) with PDT plugin installed on c:
- wamp 2.5 (php 5.5.12, apache 2.4.9)
On the desktop:
Click on windows status bar wamp icon (outside of eclipse, down on the right of your desktop)
click PHP> PHP Settings
Tick Xdebug remote debug / profiler / profiler enable trigger until it appears ticked (need to try few times before it works and errors can appear but ignore them)
click PHP> PHP.ini
!!!!WARNING!!!!
This last step is changing in fact the c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini NOT the one c:/wamp/www/bin/php/php5.5.12/php.ini but it still works as described previously
In eclipse:
Window>Preferences>PHP>PHP Executable
Window>Preferences>PHP>Debug
Window>Preferences>PHP>Debug>Installed Debugger
Window>Preferences>PHP>Servers
Select php file to debug and then Run>Debug>Debug Configurations
and finally Debug button in the same window and it should work (at least on on my machine what is not too bad after a day of looking around)
NB: It's also possible to select file on the left eclipse explorer frame > Run > Debug > Debug Configurations and the previous mydebugconfig created)
For your information end of file c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini
and end of file c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini
对于所有仍在与这个问题作斗争的人,有一些方便的提示。
检查您拥有哪个版本(包)的 Eclipse? 事实证明,当您将应用程序调试为
网络应用程序
。仅当您将其作为PHP 脚本
运行时,调试才有效。这使得它对于调试过程毫无用处。您应该考虑恢复到较旧的面向 PHP 开发人员的 Galileo Package Eclipse 或安装最新的 Eclipse Juno (甚至 Eclipse Kepler 的最新开发者版本),其中没有PDT 支持内置,但您可以使用
Help > 轻松添加它。安装新软件..
(将其指向http://download.eclipse.org/tools/pdt/updates/release
)。据报道,这些版本能够作为
Web 应用程序
进行调试,并遵守断点。另外,请记住,Xdebug 必须作为 Zend Extension 运行才能支持断点!换句话说,从
php.ini
中删除extension=xdebug.so
(在 Linux 上或xdebug.dll
在 Windows 上)行并将其替换为zend_extension=/full/path/to/xdebug.so
(在 Linux 上或zend_extension=X:\full\path\to\xdebug.dll
在 Windows 上)。 Zend 扩展需要完整路径,即使它们像常规 PHP 扩展一样放入/php/ext
文件夹中。您可以在 Xdebug 常见问题解答中找到更多信息(寻找“Xdebug”的答案仅作为 PHP 扩展加载,而不作为 Zend 扩展加载”问题)。For all those, that are still fighting with this problem, some handy tips.
Check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints, when you debug your application as
Web Application
. Debugging works only, if you run it asPHP Script
. Which makes it pretty useless for debugging process.You should consider either reverting to older Galileo Package Eclipse for PHP Developers or installing newest Eclipse Juno (or even newest developer version of Eclipse Kepler), which doesn't have PDT support build in, but you can easily add it to then, using
Help > Install New Software..
(point it tohttp://download.eclipse.org/tools/pdt/updates/release
).These versions are reported to be able to debug as
Web Application
, respecting breakpoints.Also, remember, that Xdebug must be run as Zend Extension in order to support breakpoints! In other words remove
extension=xdebug.so
(on Linux orxdebug.dll
on Windows) line from yourphp.ini
and replace it withzend_extension=/full/path/to/xdebug.so
(on Linux orzend_extension=X:\full\path\to\xdebug.dll
on Windows). Zend extensions requires full path, even if they're put into/php/ext
folder, as regular PHP extensions. You'll find more info on this in Xdebug FAQ (look for an answer to "Xdebug is only loaded as PHP extension and not as a Zend Extension" question).