使用 xdebug、netbeans 和安装的远程服务器进行调试

发布于 2024-08-18 11:24:06 字数 351 浏览 8 评论 0原文

我使用 Netbeans 在 Windows 计算机上进行开发,我正在编辑的文件位于远程 LAMP 服务器上。文档根目录作为驱动器盘符 (Y:) 安装在我的 Windows 计算机上。因此,netbeans 是我在本地开发的东西,而我实际上是在本地安装上远程开发的。

当我想使用 xdebug 和 netbeans 调试 CLI PHP 脚本时,我的问题就开始了。调试基于浏览器的东西相当简单,但调试 CLI 的东西有点复杂,我不确定我知道如何让它工作。

第一个问题是,Netbeans 想知道 php5 解释器在哪里,但我无法告诉它,因为它位于远程服务器上......

有人有这样做的经验吗?

谢谢,

迈克

I've using Netbeans to develop on a windows machine, the files I'm editing are on a remote LAMP server. The document root is mounted on my windows machine as a drive letter (Y:). So, netbeans things I'm developing locally, whereas I'm actually developing remotely on a local mount.

My problem starts when I want to use xdebug and netbeans to debug CLI PHP scripts. Debugging browser based stuff is fairly straight forward, but debugging CLI stuff is a little more convoluted and I'm not sure I know how to get it working.

The first problem is that, Netbeans wants to know where the php5 interpreter is, but I can't tell it as it's on the remote server...

Does anyone have any experience with doing this?

Thanks,

Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

千仐 2024-08-25 11:24:06

当我向我的项目添加路径映射时(在“项目选项卡|右键单击项目|属性|运行配置|高级按钮”下),Netbeans PHP 调试的关键突破就出现了,这样我的项目就知道如何将服务器源代码路径与本地路径(Windows 驱动器盘符路径)。

示例路径映射:

/home/myusername/sourcedir 映射到 x:\sourcedir

我相信我使用与您类似的配置(LAMP 服务器、Windows 计算机,LAMP 计算机的源代码显示在本地 Windows 映射驱动器下)。这对我有用。

我一直在尝试将我的项目的 URL (http://server/projectroot) 作为路径映射。那不是所需要的。需要服务器上的实际路径(即我的主目录及以下目录)。

The key Netbeans PHP debugging breakthrough came for me when I added a path mapping to my project (under Project Tab|Right-click Project|Properties|Run Configuration|Advanced Button), so that my project knew how to correlate server source code paths to the local paths (windows drive letter paths).

Example path map:

/home/myusername/sourcedir mapped to x:\sourcedir

I believe I work with a similar configuration to yours (LAMP server, windows machine with the source from the LAMP machine showing up locally under a windows mapped drive). This worked for me.

I had been trying the URLs for my project (http://server/projectroot) as the path mapping. That was not what was needed. The actual path on the server (i.e. my home directory and below) was needed.

国际总奸 2024-08-25 11:24:06

Pada 的意思是:xdebug.remote_connect_back,而不是 xdebug.remote_enable。您必须对它们进行设置,以便 Xdebug 自动连接回 Netbeans(或任何调试器)。

Pada meant: xdebug.remote_connect_back, not xdebug.remote_enable. You must have both of them set in order for Xdebug to auto-connect back to Netbeans (or whatever the debugger).

懷念過去 2024-08-25 11:24:06

xdebug.remote_host 变量指的是 xdebug 应连接的主机。您可以使用 NetBeans 在远程服务器上调试 PHP,但这需要您在远程服务器上配置 xdebug,以便它能够连接到您的开发 PC。

这是一个简单的例子:
您的开发 PC(装有 NetBeans)位于 10.0.0.100,
并且您的远程 PHP Web 服务器位于 10.0.0.1
设置xdebug.remote_host=10.0.0.100
现在,每当有人(或您)在远程服务器上的 URL 中指定 XDEBUG_SESSION_START 参数时,xdebug 就会尝试连接到 10.0.0.100。

Xdebug v2.1 有一个很好的功能:xdebug.remote_enable = 1
启用该选项将覆盖 xdebug.remote_host,然后 xdebug 将连接到 $_SERVER['REMOTE_ADDR'] (这是客户端连接的 IP 地址)。这个很棒的功能将允许您在同一服务器上进行多次调试,因为您无法使用 ini_set() 操作 xdebug.remote_host

The xdebug.remote_host variable refers to the host that xdebug should connect. You can debug PHP on a remote server using NetBeans, but it would require you to configure xdebug on the remote server such that it would connect to your development PC.

Here's a simple example:
Your development PC, with NetBeans, is on 10.0.0.100,
and your remote PHP webserver is on 10.0.0.1
Set the xdebug.remote_host=10.0.0.100
Now whenever someone (or you) specified the XDEBUG_SESSION_START parameter in the URL on the remote server, xdebug would try to connect to 10.0.0.100.

Xdebug v2.1 has a nice feature: xdebug.remote_enable = 1
Enabling that option would override xdebug.remote_host and then xdebug would connect to the $_SERVER['REMOTE_ADDR'] (which is the IP address that the client is connecting from). This awesome feature would allow you to have multiple debugging on the same server, since you can't manipulate xdebug.remote_host with ini_set()

维持三分热 2024-08-25 11:24:06

我不了解 Netbeans,从未使用过它,但是在 Eclipse PDT 中,您还可以使用 XDebug 进行调试,“PHP 网页”和“PHP 脚本”之间是有区别的。对于“PHP 网页”,您选择一个 Web 服务器(您之前配置的)而不是 php 解释器(就像您必须处理“PHP 脚本”一样)。

也许 Netbeans 也有同样的事情?

I don't know about Netbeans, never used it, but in Eclipse PDT where you can also debug using XDebug there is a distinction between "PHP web page" and "PHP script". For "PHP web page" you choose a web server (that you configured earlier) and not a php interpreter (like you have to do with "PHP script").

Perhaps there's the same thing for Netbeans?

网名女生简单气质 2024-08-25 11:24:06

xdebug.remote_autostart=1 自动远程连接。
在“Xdebug v2.1 有一个很好的功能:”中。

xdebug.remote_autostart=1 to automatic remote connection.
in "Xdebug v2.1 has a nice feature:".

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