加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

phpstorm – 无法解析外部Xdebug连接的服务器名称

发布时间:2020-12-13 21:33:15 所属栏目:PHP教程 来源:网络整理
导读:我有一个带有xdebug的Docker容器,当我运行脚本时,我需要形成我从PhpStorm收到的Docker容器,消息如下: Cannot parse server name for external Xdebug connection.To fix it create environment variable PHP_IDE_CONFIG on the remote server.Windows: set
我有一个带有xdebug的Docker容器,当我运行脚本时,我需要形成我从PhpStorm收到的Docker容器,消息如下:

Cannot parse server name for external Xdebug connection.
To fix it create environment variable PHP_IDE_CONFIG on the remote server.
Windows: set PHP_IDE_CONFIG="serverName=SomeName"
Linux / Mac OS X: export PHP_IDE_CONFIG="serverName=SomeName".

但我已经设置了这些环境变量,如下面的屏幕截图所示:

enter image description here

xdebug.log

这是我的phpinfo()的xdebug部分:

enter image description here


enter image description here

这些是我对PhpStorm的设置:

enter image description here

enter image description here

来自phpinfo()的环境:

enter image description here

来自phpinfo()的PHP变量:

enter image description here


enter image description here


enter image description here

我也尝试使用和不使用引号导出env变量,但结果是相同的…

报价:

XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"

没有引号:

XDEBUG_CONFIG=remote_host=192.168.1.110
PHP_IDE_CONFIG=serverName=docker-server

来自我的MacOS的ifconfig en1 inet命令的结果,我正在运行Docker和PhpStorm

enter image description here

您还可以在需要的情况下检查以下文件:

> Dockerfile.development
> docker-compose.yml
> environment.development
> php.ini

任何帮助都感激不尽!

更新:

似乎如果我添加

environment:
  XDEBUG_CONFIG: "remote_host=192.168.1.110"
  PHP_IDE_CONFIG: "serverName=docker-server"

进入位于docker-compose.yml内的我的php服务它解决了这个问题但是给我留下了一个很大的问题.

因为我有:

env_file:
  - ./etc/environment.yml
  - ./etc/environment.development.yml

在里面./etc/environment.development.yml我有:

XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"

并且由于它没有被忽略,我可以看到甚至在我将环境属性添加到我的php服务之前设置了那些Env变量,为什么xdebug仅在我设置环境属性时被触发?我觉得在两个地方都有重复,我更喜欢把它放在./etc/environment.development.yml而不是docker-compose.yml中.

解决方法

经过一番挖掘,

我看到了以下不同之处:

当我使用env_file指令时,我在environment.development文件中有以下内容:

XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"

结果导致:

enter image description here

注意值周围的双引号.

当我删除env_file指令并放入以下内容时:

environment:
  XDEBUG_CONFIG: "remote_host=192.168.1.110"
  PHP_IDE_CONFIG: "serverName=docker-server"

然后我在phpinfo()中有这个:

enter image description here

所以最后我做了什么,我删除了环境指令并放回了env_file指令并在environment.development文件中删除了围绕值的双引号,所以现在它看起来像这样:

XDEBUG_CONFIG=remote_host=192.168.1.110
PHP_IDE_CONFIG=serverName=docker-server

现在它工作正常:)

我在PhpStorm youtrack填写了bug report.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读