将 XDebug 与 Eclipse PDT 和 XAMPP 结合使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5279837/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:57:24  来源:igfitidea点击:

Using XDebug with Eclipse PDT & XAMPP

eclipsexamppxdebug

提问by F_C

I cannot debug a PHP script as a script. It always terminates immediately after starting. I set up an Xdebug log in my php.ini, but it's completely unhelpful. Xdebug doesshow up on my phpinfo(), so I know it's loaded in Apache.

我无法将 PHP 脚本作为脚本进行调试。它总是在启动后立即终止。我在我的 php.ini 中设置了 Xdebug 日志,但它完全没有帮助。Xdebug确实出现在我的 phpinfo() 上,所以我知道它已加载到 Apache 中。

I can also debug code as a webpage (which provides no info on variables and will not stop on breakpoints though), so I know Eclipse has the proper server settings. Both debug options use the same PHP exe (the one installed with XAMPP, php 5.3.1 compiled with vc6 compiler). I made sure that the compilation of Xdebug matched these settings.

我还可以将代码作为网页进行调试(它不提供有关变量的信息,但不会在断点处停止),所以我知道 Eclipse 具有正确的服务器设置。两个调试选项都使用相同的 PHP exe(用 XAMPP 安装的那个,用 vc6 编译器编译的 php 5.3.1)。我确保 Xdebug 的编译与这些设置匹配。

On a perhaps related note: I noticed that I could only load Xdebug with the zend_extension command, instead of zend_extension_ts even though my version of PHP is indeed thread safe? I have to admit I'm a little confused by that.

关于一个可能相关的说明:我注意到我只能使用 zend_extension 命令而不是 zend_extension_ts 加载 Xdebug,即使我的 PHP 版本确实是线程安全的?我不得不承认我对此有点困惑。

I also made very sure that wherever I could select "XDebug" in Eclipse, I did. I've followed two tutorials to no avail here. Anyone have any ideas? I've tried the version of Xdebug bundled with my XAMPP (2.0.6-dev) and I also downloaded a new .dll, version 2.1.

我还非常确定在 Eclipse 中可以选择“XDebug”的任何地方,我都选择了。我已经按照两个教程在这里无济于事。谁有想法?我已经尝试了与我的 XAMPP (2.0.6-dev) 捆绑在一起的 Xdebug 版本,并且我还下载了一个新的 .dll 版本 2.1。

Thanks!

谢谢!

回答by John Littlefield

Excellent instructions for Setup XDebug on XAMPP and Eclipse@user629300 Instructions are good for eclipse versions prior to 3.5 see the links to get instructions for version based instructions. Also Getting XDebug to work with apache xampp to debug php, has pictures with good explanations. They are a little stale though.

在 XAMPP 和 Eclipse 上设置 XDebug 的优秀说明@user629300 说明适用于 3.5 之前的 eclipse 版本,请参阅链接以获取基于版本的说明的说明。也让 XDebug 与 apache xampp 一起工作来调试 php,有很好的解释的图片。不过它们有点陈旧。



A summary of the details from the first link, assuming PHP > 5.3 (which hopefully everyone is running now!):

第一个链接的详细信息摘要,假设 PHP > 5.3(希望每个人现在都在运行!):

  • Make sure that your php.ini file contains the following:

    [XDebug]
    zend_extension={xampp-folder}\php\ext\php_xdebug.dll
    xdebug.remote_enable=1
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    
  • Remove any config entries under the [Zend]heading, particularly those starting with zend_extension
  • Configure Eclipse:
    • in Window -> Preferences -> PHP -> Servers, configure the PHP server to use XDebug, add the base URL and local web root
    • in -> Installed debuggers, configure XDebug to accept remote sessions
    • (optional?) configure the PHP executable to point to php.exe in your XAMPP installation
  • 确保您的 php.ini 文件包含以下内容:

    [XDebug]
    zend_extension={xampp-folder}\php\ext\php_xdebug.dll
    xdebug.remote_enable=1
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    
  • 删除[Zend]标题下的所有配置条目,特别是那些以zend_extension
  • 配置 Eclipse:
    • 在Window -> Preferences -> PHP -> Servers,配置PHP服务器使用XDebug,添加base URL和本地web root
    • 在 -> Installed debuggers 中,配置 XDebug 以接受远程会话
    • (可选?)将 PHP 可执行文件配置为指向 XAMPP 安装中的 php.exe

You should now be able to hit breakpoints in Eclipse by adding XDEBUG_SESSION_STARTto the query string of your URL, e.g. http://localhost/?XDEBUG_SESSION_START.

您现在应该能够通过添加XDEBUG_SESSION_START到您的 URL 的查询字符串中来在 Eclipse 中找到断点,例如http://localhost/?XDEBUG_SESSION_START.

回答by user629300

first download the dll for xDebug then edit your php.ini file zend_extension_ts = “C:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll” make sure the line is uncommented restart apache make sure you are editing the right php.ini file

首先下载 xDebug 的 dll 然后编辑你的 php.ini 文件 zend_extension_ts = “C:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll” 确保该行没有被注释 重启 apache 确保你正在编辑正确的 php.ini 文件