phpstorm 和 docker 中的 xdebug
xdebug in phpstorm and docker
我设法将 xdebug 与 docker 和 phpstorm 结合使用。对于 http 调用...IE
http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM
但是当我尝试 运行 我的 phpunit
测试时,它没有连接到 phpstorm
我在 phpstorm 中做了正确的目录映射,并且 运行 在我的 docker-实例 export XDEBUG_CONFIG="idekey=PHPSTORM"
上进行了以下操作
我还尝试了我的 docker:export PHP_IDE_CONFIG='serverName=web.docker' 并在 phpstorm web.docker 上命名了服务器配置。仍在使用 http 但不是 CLI
那么我也可以让 phpstorm 和 xdebug 一起用于命令行吗?
这是我的文件:/etc/php5/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.17.42.1
dxdebug.remote_autostart=1
当我打开日志记录并使用我得到的 xdebug_remote_host IP 地址时
W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:20:39
Log opened at 2015-10-13 12:22:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 172.17.42.1:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:22:58
Log opened at 2015-10-13 12:23:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 192.168.99.100:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:23:58
解决方案(编辑)
通过打开 xdebug 日志记录,我看到它已成功连接到 192.168.99.1
所以这解决了问题
xdebug.remote_host=192.168.99.1
我现在想到两件事:
xdebug.remote_host设置正确吗?对于 HTTP Link,您提供了一个 192.168.
地址,返回它是一个 172.17.
地址。你能在那个 IP 上 ping 你的主机吗?
在您的 ini 文件中显示:
dxdebug.remote_autostart=1
这只是一个拼写错误,还是实际上在您的配置文件中?因为它应该读取前面没有 "d" 的 xdebug。应该是:
xdebug.remote_autostart=1
你应该只在执行脚本时添加选项时添加 d:
php -dxdebug.remote_autostart=1 script.php
如果这还没有帮助,请通过在配置中添加如下内容来启用远程日志:
xdebug.remote_log = /var/log/xdebug_remote.log
也许这会有助于找到问题。
对我有用的是具有此配置的 ssh 隧道
xdebug.remote_connect_back=0
xdebug.remote_host=127.0.0.1
参见:
自 Docker-17.06 起,您可以通过静态主机名 docker.for.mac.localhost
访问 Container 中托管在 Mac 上的服务
完整答案在这里:
我设法将 xdebug 与 docker 和 phpstorm 结合使用。对于 http 调用...IE
http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM
但是当我尝试 运行 我的 phpunit
测试时,它没有连接到 phpstorm
我在 phpstorm 中做了正确的目录映射,并且 运行 在我的 docker-实例 export XDEBUG_CONFIG="idekey=PHPSTORM"
我还尝试了我的 docker:export PHP_IDE_CONFIG='serverName=web.docker' 并在 phpstorm web.docker 上命名了服务器配置。仍在使用 http 但不是 CLI
那么我也可以让 phpstorm 和 xdebug 一起用于命令行吗?
这是我的文件:/etc/php5/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.17.42.1
dxdebug.remote_autostart=1
当我打开日志记录并使用我得到的 xdebug_remote_host IP 地址时
W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:20:39
Log opened at 2015-10-13 12:22:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 172.17.42.1:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:22:58
Log opened at 2015-10-13 12:23:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 192.168.99.100:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:23:58
解决方案(编辑)
通过打开 xdebug 日志记录,我看到它已成功连接到 192.168.99.1
所以这解决了问题
xdebug.remote_host=192.168.99.1
我现在想到两件事:
xdebug.remote_host设置正确吗?对于 HTTP Link,您提供了一个
192.168.
地址,返回它是一个172.17.
地址。你能在那个 IP 上 ping 你的主机吗?在您的 ini 文件中显示:
dxdebug.remote_autostart=1
这只是一个拼写错误,还是实际上在您的配置文件中?因为它应该读取前面没有 "d" 的 xdebug。应该是:
xdebug.remote_autostart=1
你应该只在执行脚本时添加选项时添加 d:
php -dxdebug.remote_autostart=1 script.php
如果这还没有帮助,请通过在配置中添加如下内容来启用远程日志:
xdebug.remote_log = /var/log/xdebug_remote.log
也许这会有助于找到问题。
对我有用的是具有此配置的 ssh 隧道 xdebug.remote_connect_back=0 xdebug.remote_host=127.0.0.1
参见:
自 Docker-17.06 起,您可以通过静态主机名 docker.for.mac.localhost
完整答案在这里: