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

我有一个带有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.

相关文章

createdtime20211113updatedtime20211113authorvenki.chen说...
Phpstorm是大多数PHP程序员们爱不释手的一款编码的集成开发工...
 PHPStorm设置打开您的项目,一旦打开,转到首选项并在语言...
前言:简单介绍下为什么要用断点调试,很多人说我在代码调试...
所以我在PHPStorm7.1中运行PHPUnit,但是我无法找到如何在测试...
参考:下载合适的XDebug点击这里,选择合适xdebugXAMPP配置p...