使用 Netbeans 和 XDebug 进行远程 PHP 调试 [英] Remote PHP Debugging with Netbeans and XDebug

查看:37
本文介绍了使用 Netbeans 和 XDebug 进行远程 PHP 调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在以下场景中使用 XDebug

I'm trying to use XDebug in the following scenario

  • Windows 7 上的物理主机,带有 Netbeans 7.1.1
  • Ubuntu 上的虚拟来宾,带有 Apache 服务器和 PHP 5.3.10
  • 我网站的 PHP 代码位于 Ubuntu 的共享文件夹中,位于/var/www/mysite
  • PHP 代码可从我的 Windows 主机访问 \guestIPmysite,并具有 R/W 权限
  • 从主机和访客都可以从 http://mysite.local.fr 访问的网站
  • Physical Host on Windows 7, with Netbeans 7.1.1
  • Virtual guest on Ubuntu, with Apache server and PHP 5.3.10
  • the PHP code of my website is on a shared folder on Ubuntu, in /var/www/mysite
  • the PHP code is accessible from my Windows host, on \guestIPmysite, with R/W permissions
  • Website accessible from http://mysite.local.fr, from both host and guest

我从我的 Windows 主机创建了一个 Netbeans 项目,指向 \guestIPmysite.在项目运行配置中,我有以下内容:

I created a Netbeans project from my Windows Host, pointing to \guestIPmysite. In the project Run configuration, I have the following:

  • 运行方式:本地网络服务器
  • 项目网址:http://mysite.local.fr
  • 索引文件:index.php(项目中确实存在)

在高级运行配置中:

  • 我选中了每次都询问"(我也尝试使用不询问"并自己使用会话密钥启动浏览器)
  • 我尝试为映射设置 '/var/www/mysite' - \GuestIPmysite(并尝试不使用任何内容)
  • 我没有触及代理设置

我的 Ubuntu VM 上的 php.ini 中有以下内容

I have the following in the php.ini on my Ubuntu VM

xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = /tmp
;xdebug.remote_host=localhost,<HostIP>, mysite.local.fr
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.idekey="netbeans-xdebug"
xdebug.remote_mode=req

这些都不起作用,Netbeans 不会在 Windows 的任何断点处停止.

None of this works, Netbeans does not stop at any breakpoint from Windows.

使用 Netbeans 直接从我的 VM 调试工作正常.

谁能告诉我如何让我的调试器从 Windows 远程工作?谢谢

Can someone tell me how to get my debugger to work remotely from Windows? Thanks

推荐答案

抱歉,我不能再发表评论了.@David @JamesB41:我也在找这个.我的设置是带有 NetBeans 7.1 的 Windows 7 主机和 VirtualBox 中的 Ubuntu VM.我将 NetBeans 项目设置为远程项目,使用 SFTP 上传和下载.

Sorry, i can't comment anymore. @David @JamesB41: I've been looking for this too. My setup is a Windows 7 host with NetBeans 7.1, and an Ubuntu VM in VirtualBox. I have the NetBeans project set up as a remote project, uploading and downloading using SFTP.

以下设置对我有用,只需使用您主机的 IP 作为 remote_host,并确保 VM 可以看到它.

The following setup works for me, just use your host's IP as remote_host, and make sure the VM can see it.

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=10.217.165.193
xdebug.remote_port=9000
xdebug.remote_log="/tmp/log/xdebug.log"

NetBeans 将在入口点断点处停止(如果您在 PHP->Debugging 中设置了选项).但是,它不会在 NetBeans 创建的断点处停止,因为它会运行 VM 的文件.不过,您可以使用 xdebug_break(),它会显示堆栈和变量. 如果您在项目配置 > 运行配置 > 高级中正确映射文件夹,它将在 NetBeans 断点处停止并突出显示.惊人的.我完整了.

NetBeans will stop at the entry point breakpoint (if you have the option set in PHP->Debugging). But, it won't stop on NetBeans-created breakpoints, because its running off the VM's files. You can use xdebug_break() though, and it will show stack and variables. It will stop at NetBeans breakpoints and highlight if you map the folders correctly in project config > Run Config > Advanced. Awesome. I am complete.

(connect_back 配置似乎没有帮助,可能是因为没有填充 $_SERVER['REMOTE_ADDR'].)

(The connect_back config didn't seem to help, possibly because $_SERVER['REMOTE_ADDR'] isn't populated.)

这篇关于使用 Netbeans 和 XDebug 进行远程 PHP 调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆