简体   繁体   English

在eclipse中使用XDebug远程调试时,PHP源文件是否需要在本地和远程存在?

[英]Do PHP source files need to exist locally AND remotely when using XDebug remote debugging in eclipse?

I'm really confused about XDebug remote debugging using Eclipse. 我对使用Eclipse的XDebug远程调试感到困惑。

I use Windows (with eclipse and all that jazz) to do my development, but I would like to test my code in the same environment as my production environment. 我使用Windows(使用eclipse和所有爵士乐)来进行开发,但我想在与生产环境相同的环境中测试我的代码。

I have been tinkering with XDebug remote debugging to support this. 我一直在修补XDebug远程调试以支持这一点。 I have correctly configured XDebug on the remote machine and made sure the ports were open. 我已在远程计算机上正确配置了XDebug,并确保端口已打开。 But what's really puzzling me is - do the source files on my machine need to also exist on the remote server running PHP and XDebug? 但令我感到困惑的是 - 我的机器上的源文件是否也需要存在于运行PHP和XDebug的远程服务器上? Right now I do not have any PHP executables on my local development machine so there's no possible way the scripts can be run on it. 现在我在我的本地开发机器上没有任何PHP可执行文件,因此没有可能在其上运行脚本。

Thanks 谢谢

Yes, the identical set of files needs to exist on the server and client. 是的,服务器和客户端上需要存在相同的文件集。

The files on the server are the ones that actually get run during your debugging session. 服务器上的文件是在调试会话期间实际运行的文件。

The files on the client are what Eclipse will show you when the debugger halts at a breakpoint. 客户端上的文件是Eclipse在调试器在断点处停止时将向您显示的内容。 The server will tell Eclipse that it stopped at line X of file Y, and Eclipse will show you line X of file Y from the local file set. 服务器将告诉Eclipse它在文件Y的第X行停止,Eclipse将从本地文件集向您显示文件Y的第X行。 So if the local file is different from the remote file, you'll be debugging the wrong thing and it will be chaos. 因此,如果本地文件与远程文件不同,您将调试错误的东西,它将是混乱的。

Note that it doesn't matter if you can't run PHP on the client. 请注意,如果您无法在客户端上运行PHP,则无关紧要。 The client files aren't being executed, just displayed in the debugging session. 客户端文件未执行,只显示在调试会话中。

If you make any edits to the local files, you'll need to resynchronize them with the server. 如果对本地文件进行任何编辑,则需要将它们与服务器重新同步。 There are several methods for doing that, some built into Eclipse, in the RSE plugin for example. 有几种方法可以做到这一点,例如,一些内置于Eclipse中的RSE插件。 I prefer to use Unison , or a version control commit back to the server. 我更喜欢使用Unison或版本控制提交回服务器。

XDebug can be used in a couple different ways, but yes, it is typical to have source files both locally and remotely. XDebug可以以多种不同的方式使用,但是,通常在本地和远程都有源文件。 I've not used Eclipse, but typically in this configuration the IDE will perform a file upload when you "Run" the project to make sure the server has the code you're editing locally. 我没有使用Eclipse,但通常在此配置中,当您“运行”项目时,IDE将执行文件上载,以确保服务器具有您在本地编辑的代码。

I prefer a setup where the files exist only on the server, but are mounted locally (over SFTP or SMB). 我更喜欢这样的设置,其中文件仅存在于服务器上,但是本地安装(通过SFTP或SMB)。 There's no need to upload files every time you run the project that way, but there's some extra work setting up path mapping so that when XDebug on the server reports "line 10 of /var/www/foo", your local IDE understands that means "line 10 of ~/MyProject/foo". 每次以这种方式运行项目时都不需要上传文件,但是还有一些额外的工作设置路径映射,以便当服务器上的XDebug报告“/ var / www / foo的第10行”时,您的本地IDE了解这意味着“〜/ MyProject / foo的第10行”。

I can't be more specific without knowing how your Eclipse project and server are setup. 如果不知道如何设置Eclipse项目和服务器,我就不能更具体了。

Also, you may want check out NetBeans (free), or PHPStorm (not free, but better) for PHP development. 此外,您可能需要查看NetBeans(免费)或PHPStorm(不是免费的,但更好)用于PHP开发。 I've heard from coworkers that Eclipse can be flaky with XDebug (they were using Windows). 我从同事那里听说Eclipse可以使用XDebug(他们使用的是Windows)。 I've never had the same issues on Linux with NetBeans or PHPStorm, though I have had similar flakiness on a Mac running NetBeans. 我在使用NetBeans或PHPStorm的Linux上从未遇到过同样的问题,尽管我在运行NetBeans的Mac上有类似的瑕疵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM