XAMPP 1.7.3、Eclipse PDT 和XDebug - 在 Eclipse 中调试 PHP 网页永远不会在断点处停止

发布于 2024-09-14 17:27:09 字数 2711 浏览 6 评论 0原文

我的开发 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烧了回忆取暖 2024-09-21 17:27:09

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.

灯下孤影 2024-09-21 17:27:09

这“可能”对一些在 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

    • 在末尾添加xdebug.remote_port=9001
    • 保存并重新启动所有 wamp 服务

!!!警告!!!!
这最后一步实际上正在改变 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

  • Executable Path c:/wamp/bin/php/php5.5.5.12/php.exe (browsed)
  • SAPI: CLI

Window>Preferences>PHP>Debug

  • 检查/设置服务器设置 Zend 调试器
  • 检查/设置 CLI 设置 Xdebug

窗口 > 首选项 > PHP > 调试 > 安装的调试器

  • Xdebug 端口 9001

窗口 > 首选项 > PHP > 服务器

  • 调试器:Zend 调试器

选择要调试的 php 文件,然后运行 ​​> 调试 > 调试配置

  • 给出名称 ex mydebugconfig
  • 单击(空白页图标)添加 Web 应用程序
  • 选择要调试的文件的路径
  • 选择缩略图服务器并选择默认 PHP Web 服务器
  • 单击配置并检查是否选择了 Zend 调试器
  • 选择缩略图调试器并检查服务器调试器 Xdebug
  • 单击配置并检查/设置端口为 9001
    最后在同一窗口中单击“调试”按钮,它应该可以工作(至少在我的机器上,经过一天的环顾后,这还不算太糟糕)

注意:也可以在左侧 Eclipse 资源管理器框架上选择文件 >运行>调试>调试配置和先前创建的 mydebugconfig)

供您参考文件 c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini 结尾

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0

和文件 c:/wamp/www/bin/apache/apache2 结尾.4.9/bin/php.ini

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
xdebug.remote_port=9001

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

    • Add at the end xdebug.remote_port=9001
    • Save and restart all wamp services

!!!!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

  • Executable path c:/wamp/bin/php/php5.5.5.12/php.exe (browsed)
  • SAPI: CLI

Window>Preferences>PHP>Debug

  • Check/set server settings Zend debugger
  • Check/set CLI settings Xdebug

Window>Preferences>PHP>Debug>Installed Debugger

  • Xdebug Port 9001

Window>Preferences>PHP>Servers

  • Debugger: Zend Debugger

Select php file to debug and then Run>Debug>Debug Configurations

  • give a name ex mydebugconfig
  • click (blank page icon) Add Web Application
  • select path to the file to debug
  • select thumbnail Server and select Default PHP Web server
  • click Configure and check if Zend Debugger is choosen
  • select thumbnail Debugger and check Server Debugger Xdebug
  • click Configure and check/set port to 9001
    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

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0

and end of file c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
xdebug.remote_port=9001
甜嗑 2024-09-21 17:27:09

对于所有仍在与这个问题作斗争的人,有一些方便的提示。

检查您拥有哪个版本(包)的 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 as PHP 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 to http://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 or xdebug.dll on Windows) line from your php.ini and replace it with zend_extension=/full/path/to/xdebug.so (on Linux or zend_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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文