我在使用以下设置让 PhpStorm 2020.2 与 xdebug 一起使用时遇到问题:
WSL2 运行 Ubuntu 20,安装了 PHP 和 php-xdebug。每当我在启用调试的情况下运行测试时,它都会显示“未建立连接。”。
这是 Xdebug 日志显示的内容:
[5877] Log opened at 2020-08-14 17:20:45
[5877] I: Connecting to configured address/port: 172.18.48.1:9006.
[5877] E: Time-out connecting to client (Waited: 200 ms). :-(
[5877] Log closed at 2020-08-14 17:20:46
这仅适用于 CLI,我不想通过 php-fpm 连接(所以没有 Apache、nginx,...)。
到目前为止我已经尝试过:
-
将端口更改为 9000 以外的端口(端口扫描还显示它们都没有在使用中)。
-
添加防火墙规则以允许传入请求,如中所述https://github.com/microsoft/WSL/issues/4585#issuecomment-610061194(以及添加规则后重新启动几次)
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
-
添加选项,例如xdebug.remote_enable=1
到配置,但无论如何,当它运行远程 php 实例时,这是由 PhpStorm 完成的(remote_connect_back
也没有做到这一点):
[wsl://UBUNTU2004]:php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9006 -dxdebug.remote_host=172.18.48.1 /home/spaceemotion/code/xxxxxx/backend/vendor/phpunit/phpunit/phpunit [rest ommitted]
任何帮助将非常感激!
As per: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000436444/comments/360000168070
在 Windows 控制面板 > Windows 防火墙 > 允许程序或功能通过 Windows 防火墙中,您可以看到允许通过专用和公共网络进行通信的软件列表。
确保 phpstorm.exe 确实被允许(对我来说,私有网络选项未被选中)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)