[英]Use Xdebug with PhpStorm and WSL
我使用 Windows 10 中的 WSL (Ubuntu 16.14) 作为具有 PHP 7.1 fpm 和 Apache 的 Web 服务器。
我想将 PhpStorm 2018 中的 Xdebug 与 WSL 一起使用,但效果不佳。
Xdebug 安装在我的 Ubuntu 服务器上并且运行良好,我在phpinfo()
输出中看到它。
这里是 Xdebug 的 php.ini 配置:
[Xdebug]
zend_extension="/usr/lib/php/20170718/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM
我也将phpstorm中的端口配置为9001。
问题更多在于 PhpStorm 和 WSL 之间的连接。 我尝试使用远程方式。 在Run > Edit config
弹出窗口中,我使用 PHP Web Page,当我使用 Validate 工具时,除了远程主机之外一切正常。 我将其设置为 127.0.0.1,这就是重点。
听调试工具提示:9001端口忙
如何在 localhost 和 localhost 之间建立链接?
我正在使用 Windows 10 中的 WSL(Ubuntu 20.04 LTS)作为带有 PHP 7.4 fpm 的 Web 服务器和带有 Xdebug 版本 3.0.4 的 Apache
以下是在 PHPSTORM 中配置 Xdebugger 的步骤,它适用于我:
安装 Xdebug
在 cli 解释器中选择 wsl
要获取 client_host,请在 ubuntu 中运行ifconfig或在 bash 中运行ipconfig
打开下面的文件
sudo vi /etc/php/7.4/cli/conf.d/20-xdebug.ini
在上面的文件中添加以下内容
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=[ip4 address/Client_host]
xdebug.remote_connect_back=On
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
xdebug.start_with_request=yes
xdebug.remote_log=/tmp/xdebug.log
然后使用 Xdebugger chrome 扩展(xdebugger helper)
重新启动 apache 服务器。
给文件添加断点并刷新页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.