問題描述
我正在嘗試在以下場景中使用 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 調試的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!