我有一个带有 xdebug 的 Docker 容器,当我运行脚本时,我需要形成 Docker 容器,我从 PhpStorm 收到以下消息:
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".
但我已经设置了这些环境变量,如您在此处的屏幕截图中看到的:
xdebug.log https://gist.github.com/panosru/76181f67e10faec8f23aea611f3d0cdb
Here is the xdebug section from my phpinfo()
:
这些是我对 PhpStorm 的设置:
环境来自phpinfo()
:
PHP 变量来自phpinfo()
:
我也尝试过export
带引号和不带引号的 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
结果来自ifconfig en1 inet
来自运行 Docker 和 PhpStorm 的 MacOS 的命令
如果需要,您还可以检查以下文件:
- Dockerfile.development https://gist.github.com/panosru/b9acf5cd98b73af50ce0f3012f2d187e
- docker-compose.yml https://gist.github.com/panosru/a6d08a1a10b96c9f6f731feb34d5808c
- 环境.发展 https://gist.github.com/panosru/cbe5cea49b9e45c7435a8ad71c986036
- php.ini https://gist.github.com/panosru/2f2134d8bb19977227cf93845d1f3ca2
任何帮助都感激不尽!
Update:
似乎如果我添加
environment:
XDEBUG_CONFIG: "remote_host=192.168.1.110"
PHP_IDE_CONFIG: "serverName=docker-server"
into my php
位于 docker-compose.yml 内的服务解决了问题,但给我留下了一个大问题。
因为我有:
env_file:
- ./etc/environment.yml
- ./etc/environment.development.yml
和里面./etc/environment.development.yml
I have:
XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"
因为它没有被忽略,所以我可以看到这些环境变量甚至在我添加之前就已设置environment
财产进入我的php
服务,为什么只有当我设置了xdebug时才会触发environment
财产?对我来说,在两个地方都有它感觉像是重复,我更喜欢把它放在里面./etc/environment.development.yml
而不是docker-compose.yml
.