使用Xdebug和Netbeans在本地主机上远程调试PHP网站的正确方法


Proper Way in using Xdebug and Netbeans for Remote Debugging PHP website on a localhost machine

使用xdebug和netbeans配置进行远程调试时遇到问题。

我可以在localhost上使用xdebug和netbeans进行调试,它运行得很好。。但在远程服务器上,当我设置断点并调试文件时,它不会在任何断点上停止。我不知道我刚开始做这件事,还错过了什么。。到目前为止,这是我的基本设置。

在我的php.ini文件上

zend_extension = "c:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9-x86_64.dll"
[xdebug]
xdebug.remote_enable = 1
xdebug.remote_host=localhost
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"

在我的netbeans上,我已经配置了远程连接,并且可以很好地处理连接。这里是运行配置的设置

Run As = Remote Web Site (FTP, SFTP)
Project Url =  http://www.somewebsite.com/
Index File = index.php
Arguments = none since it has n arguments at first
inside Remote Connection :  
host Name = host IP(eg 69.123.123.123)
encryption = Pure Ftp
username = someuser
password = somepassword
initial directory = /
timeout = 30
keep alive interval = 30
Passive mode = checked
Upload directory = blank
Upload Files = manually

希望有人能帮我指出我缺少什么和该做什么,我很难理解这方面的一些技术配置,如果你能一步一步地帮助我,我知道我可以遵循。期待着这一点。谢谢

您需要进行路径映射,否则netbeans会在错误的路径上设置断点。如果您制作远程日志文件(http://xdebug.org/docs/all_settings#remote_log)您将看到它在哪些路径上设置断点。请参阅https://blogs.oracle.com/netbeansphp/entry/path_mapping_in_php_debugger有关路径映射的信息。

您必须将远程主机设置为运行Netbeans的机器的名称或IP,而不是localhost。

xdebug.remote_host=localhost

更改为例如:

xdebug.remote_host=192.168.0.10

原因是,服务器上的Xdebug会尝试连接到Netbeans机器进行调试,而不是相反,所以服务器需要知道"远程"机器的地址。

哦,还要确保您的本地windows防火墙允许从9000端口的服务器进行连接。