简体   繁体   English

手动断点不适用于PHP的XDebug中的远程VM

[英]Manual breakpoints not working on remote VM in XDebug for PHP

I've been setting up XDebug for PHP on a remote VM, with PHPStorm as the IDE/client. 我一直在使用PHPStorm作为IDE /客户端的远程VM上设置XDebug for PHP。 I see a lot of questions about this on the site, but none about this situation... 我在网站上看到很多与此有关的问题,但没有关于这种情况的问题...

I'm coding on a Windows machine, with PHPStorm synchronizing files automatically with my dev environment on a Linux VM. 我在Windows机器上编码,PHPStorm与Linux VM上的开发环境自动同步文件。 I have a tunnel on port 9001 from that VM back to my local machine. 我在从该VM返回我的本地计算机的端口9001上建立了一条隧道。 I'm trying to debug command line PHP scripts, and I've got this far: 我正在尝试调试命令行PHP脚本,到目前为止,我已经做到了:

  • The xdebug_break() function works. xdebug_break()函数起作用。
  • If 'Break at first line in PHP scripts' is checked, I can step through scripts from the beginning, but... 如果选中“在PHP脚本的第一行中断”,则可以从头开始逐步执​​行脚本,但是...
  • Manual breakpoints don't work! 手动断点不起作用!

Communication between my IDE and the XDebug instance seems to be fine, as I'm able to step through as long as it's from an xdebug_break() or the start of a script (though the IDE doesn't highlight the current line). 我的IDE和XDebug实例之间的通信似乎很好,因为只要它来自xdebug_break()或脚本的开始(尽管IDE不会突出显示当前行),我就可以逐步进行通信。

Looking at the xdebug.remote_log, I see the breakpoint being set on my local, Windows file instead of the path on the server - this seems like a problem... 查看xdebug.remote_log,我看到在本地Windows文件中设置了断点,而不是服务器上的路径-这似乎是一个问题...

<- breakpoint_set -i 7 -t line -f file://D:/git/php/php/tests/lookatme.php -n 8

(The double php/php is correct.) (双重php / php是正确的。)

If I trick it by symlinking a "/D:/git/php/php/" directory on my VM to the actual PHP directory and then run a PHP script, it actually works – but only if PHP is run from the root directory. 如果我通过将VM上的“ / D:/ git / php / php /”目录符号链接到实际的PHP目录然后运行PHP脚本来欺骗它,则它确实可以工作-但前提是必须从根目录运行PHP。

As far as I know, my mapping in Settings/PHP/Servers is correct - am I right in thinking that only the root folder of my PHP repository needs to be mapped to its equivalent on the remote server? 据我所知,我在Settings / PHP / Servers中的映射是正确的-我是否认为只有PHP存储库的根文件夹需要映射到远程服务器上的等效文件夹?

D:\git\php\php -> /company/mnt/codebase/DEVWEB/php/

My xdebug.ini: 我的xdebug.ini:

xdebug.default_enable=0
xdebug.overload_var_dump=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name="cachegrind.out.%s.%t"
xdebug.remote_enable=On
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9001
xdebug.remote_log=/tmp/xdebug.log

Scripts are run with the environment variable: 脚本使用环境变量运行:

export XDEBUG_CONFIG="idekey=PHPSTORM"

Path mappings in PHPStorm: PHPStorm中的路径映射:

http://i.imgur.com/Unp2BgG.png http://i.imgur.com/Unp2BgG.png

Thanks for any thoughts! 感谢您的任何想法!

Thanks for everyone's help and pointers - in the end it turned out I was missing an environment variable on my remote machine: 感谢大家的帮助和指点-最终我发现我的远程机器上缺少一个环境变量:

export PHP_IDE_CONFIG="serverName=RemotePHP" 导出PHP_IDE_CONFIG =“ serverName = RemotePHP”

where RemotePHP is the name of the server set up in Settings > PHP > Servers and selected in the debug configuration. 其中,RemotePHP是在“设置”>“ PHP”>“服务器”中设置并在调试配置中选择的服务器的名称。 Presumably, without this it didn't know how to map the incoming breakpoint to the right file. 据推测,没有它,它不知道如何将传入的断点映射到正确的文件。

I think you need to map every single file. 我认为您需要映射每个文件。 It works for me with a remote server. 它适用于远程服务器。

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

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