我在wsl 2上安装了一个名为“micro-env”的docker
WSL 2固定IP为:
172.23.183.202
我想在phpstorm中添加xdebug 3,xdebug安装在php 7 docker容器中。
这是命令的输出:
docker inspect groomrhv2-php -f "{{json .NetworkSettings.Networks }}" --format json | jq .
输出量:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "7293963ad4db7c70a3c7e4c24fb7c4e04c26cf4c2c2723a55272aeba90b8fd37",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "443"
},
{
"HostIp": "::",
"HostPort": "443"
}
],
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
},
{
"HostIp": "::",
"HostPort": "8080"
}
],
"9000/tcp": null
},
"SandboxKey": "/var/run/docker/netns/7293963ad4db",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"groomrhv2_dockerized_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"groomrhv2-php",
"groomrhv2-php",
"c1aa5080ef3e"
],
"NetworkID": "3fb9d9c63780fe121610305d6d164d70508c1ebb3c7de9267ddbba3feff39b58",
"EndpointID": "e717eecc4374e4f025bf83b98945d87bd8e973ebd7a53d11538fa10bb460f064",
"Gateway": "172.22.0.1",
"IPAddress": "172.22.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:16:00:05",
"DriverOpts": null
}
}
}
}
然后在容器内:
docker exec -ti groomrhv2-php bash
容器内php --ini的输出:
Cannot load Xdebug - it was already loaded
Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File: (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed: /usr/local/etc/php/conf.d/docker-php-ext-config.ini,
/usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-intl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
/usr/local/etc/php/conf.d/error_reporting.ini,
/usr/local/etc/php/conf.d/opcache.ini,
/usr/local/etc/php/conf.d/xdebug.ini
xdebug扩展位于:/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
文件名:/usr/local/etc/php
在phpstorm中我添加了docker:
然后我添加了php cli解释器,如下所示:
这是我的xdebug.ini配置:
[xdebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.mode=debug,develop,profile
xdebug.discover_client_host=false
xdebug.client_host=172.23.183.202
xdebug.client_port=9000
xdebug.start_with_request=yes
xdebug.idekey=GroomRHV2
XDEBUG_SESSION=GroomRHV2
xdebug.cli_color=1
xdebug.log_level=3
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
然后我尝试在Web服务器上验证调试器conf:
这就是我最终得到的:
我目前还不能在phpstorm中使用xdebug 3,如果有人能帮助我,我将不胜感激!谢谢
1条答案
按热度按时间hrirmatl1#
在我的例子中,通过向**.env**文件添加一个选项(docker-compose必须有)解决了同样的问题,或者您可以修复xdebug.ini,如果可以访问的话
172.28.80.1 -我的本地主机IP(PhpStorm在这里工作)
原因原来是PHP不是敲我的Windows计算机上安装的IDE(172.28.80.1),但在WSL虚拟机的IP(10.5.0.1)和重要的是设置discover_client_host=0,因为我们不需要自动打开套接字的xclock与失败的10.5.0.1:9003连接.
你也可以在index.php文件的顶部插入xdebug_info()函数,看看xdebug实际上试图访问的位置:
您可以查看本地主机netstat -na上打开的端口|查找“9003”
Localhost IP mast是pingable从您的php容器与index.php,检查它通过ping,或检查与telnet
最后一点是可选的,如果没有它,xtag 3将已经工作,但不会显示调试器停止在哪一行,它将向 Storm 指示您的本地服务器和文件在真实的磁盘上的位置以及它们在容器
中的相应位置