phpstorm xdebug远程SSH对vagrant断点上的CLI脚本调试未触发
我正在尝试在Windows计算机上本地检查的PHP脚本,然后映射到已安装NginX,PHP和XDEBUG的Ubuntu VM(使用Vagrant配置)。同样,重要的是要指出,我在此设置中有PHP-FPM工作,并且我也运行了一个PHP脚本,但在VSCODE中,而不是PHPSTOMS。
我的phpstorm配置是:
我的XDebug config(当前,我现在尝试了一百万个不同的配置):
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_enable=1
然后,我像这样配置了我的SSH隧道:
putty.exe -ssh <vm-ip> -R 9003:localhost:9003
我能够运行文件并在中获取其输出phpstorm,但我的断点不起作用。我只得到以下内容:
这是我要调试的PHP文件的内容:
< img src =“ https://i.sstatic.net/sebsy.png” alt =“在此处输入图像说明”> ,
因此,如我们所见,脚本无问题,这些断点不会触发。 。如前所述,在调试网站时,我有Xdebug在phpstorm中用于php-fpm,但是在尝试调试单个PHP脚本时,我会遇到此问题。
我尝试了许多不同的事情,这使我确信我忽略了我忘记的基本内容。现在,我怀疑phpstorm感到烦人。.在输出时,我们可以看到脚本被调用:
[vagrant://C:\vagrant]:/usr/bin/php -dxdebug.mode=debug -dxdebug.client_port=9002 -dxdebug.client_host=192.168.1.185
我尚未在任何地方输入这些-d
参数,我不确定为什么phpstorm会继续添加它们(也它使用端口9002,我配置了9003)。但是我也无法在VScode中使用任何工作,因此我做错了什么。
我当前在phpstorm中工作的PHP-fpm的XDEBUG配置是:
zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.idekey=PHPSTORM
xdebug.output_dir=/tmp/xdebug
xdebug.log=/tmp/xdebug/xdebug.log
xdebug.remote_log=/root/logs/xdebug.log
xdebug.force_display_errors=1
xdebug.force_error_reporting=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_autostart=1
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_connect_back=0
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
..然后,我有一个php |服务器
也为此设置:
如果我尝试将此配置用于php cli脚本调试,它也无法正常工作(+它的phpstorm等待xdebug连接,我猜这有点有效与PHP CLI脚本调试不同)
我在运行单个CLI脚本时没有触发什么错?
I am trying to debug a PHP script which is checked out locally on a Windows machine, then mapped to a Ubuntu VM (configured using Vagrant) which have Nginx, PHP and Xdebug installed. Also it's important to point out that I have php-fpm working in this setup and I have had a PHP script running as well, but in VSCode and not PhpStorm.
My PhpStorm config is:
My Xdebug config (currently, I have tried a million different config now):
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_enable=1
I then configure my SSH tunnel like so:
putty.exe -ssh <vm-ip> -R 9003:localhost:9003
I am able to run the file and get its output in PhpStorm, but my breakpoints are not working. I just get the following:
And this is the content of the php file I am trying to debug:
So as we can see, the script executes without problem, the breakpoints just don't trigger. And as mentioned I have Xdebug working in PhpStorm for php-fpm when debugging websites, but when trying to debug a single PHP script I run into this problem.
I have tried so many different things, which makes me sure I am overlooking something basic I have forgotten. Right now I am suspecting PhpStorm for being annoying.. on output we can see the script is invoked with:
[vagrant://C:\vagrant]:/usr/bin/php -dxdebug.mode=debug -dxdebug.client_port=9002 -dxdebug.client_host=192.168.1.185
I have not entered these -d
arguments anywhere and I am not sure why PhpStorm keeps adding them (also it uses port 9002 and I have configured 9003). But I am not able to get anything working in VSCode as well, so I am properly doing something wrong.
My Xdebug config for php-fpm which is currently working in PhpStorm is:
zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.idekey=PHPSTORM
xdebug.output_dir=/tmp/xdebug
xdebug.log=/tmp/xdebug/xdebug.log
xdebug.remote_log=/root/logs/xdebug.log
xdebug.force_display_errors=1
xdebug.force_error_reporting=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_autostart=1
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_connect_back=0
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
.. i then have a PHP | Servers
settings for this as well:
If I try to use this config for PHP CLI script debugging, it's not working either (+ its PhpStorm waiting for Xdebug connections which I guess works a bit differently from PHP CLI script debugging)
What am I doing wrong since my breakpoints are not triggering when running single CLI scripts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方案,它很愚蠢
。 :
我没有为这些
-d
参数介绍,也无法为我的终生弄清楚如何使phpstorm删除它们。.如问题评论中所述,该端口是通过设置指定的| php |调试| “调试端口”至少我可以更改。我要修复的是,只是再次覆盖它,因此在VM上执行的CMD最终是这样的(obs:我已经使用了许多不同的端口来尝试修复它。这就是为什么我现在使用9004) :
我的猜测是,这覆盖了第一个,错误的争论,然后使一切正常。
您可以通过在您的运行中添加类似的参数来做到这一点:
和我最终使用的Xdebug config,现在匹配了我在SSH调试中发现的所有指南,并且仅是:
成功! :d
I found a solution, it stupid but it works..
So essentially what annoyed me a lot, was that PHPSTORM added intepretor arguments which i did not specify, which i also mentioned above in the question.. it ended up executing the following on VM:
I did not spoecify these
-d
arguments and could not for the life of me figure out how to make PHPSTORM remove them.. as mentioned in the question comments the port is specified through settings | php | debug | "debug port" so at least i could change that.. but the client_host was still wrong.What i did to fix is, is just overriding it again so the cmd executed on the VM ended up being this (obs: i have used a lot of different ports to try and fix it.. which is why i am now using 9004):
My guess is this overrides the first, wrong, argument and then makes everything work.
You do this by adding intepretor arguments like so in your run-configuration:
and the xdebug config i ended up with, now matches all the guides i have found on SSH debugging as well, and is only:
Success! :-D