【发布时间】:2016-01-07 10:29:54
【问题描述】:
我设法将 xdebug 与 docker 和 phpstorm 结合使用。对于 http 调用...IE
http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM
但是当我尝试运行我的phpunit 测试时,它没有连接到 phpstorm
我在 phpstorm 中进行了正确的目录映射,还在我的 docker-instance 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
【问题讨论】:
-
对于远程调试 IDE 使用服务器/主机名作为唯一 id 来决定使用哪些路径映射 (
PHP | Servers)。对于 CLI 调试,未提供此类信息(无处可取),因此您需要手动提供(类似于您对 idekey 所做的)-serverName=ServerNameHere。还有——devnet.jetbrains.com/message/5534075#5534075 -
我没有 100% 理解您的提示,但无论如何我在我的 docker 上进行了尝试:
export PHP_IDE_CONFIG='serverName=web.docker'并在 phpstorm web.docker 上命名了服务器配置。仍然在 http 但不是 CLI 上工作 -
1) 你可以阅读远程 CLI 调试/serverName 参数here 2) 你的
PHP | Servers是什么样子的(请截图) 3) 在调试 PHPUnit 之前 .. 尝试调试简单的脚本(放置它在你的项目根目录中;当然是本地和远程的)——至少你会保证它不能在整体上进行调试,而不是 phpunit 特定的时刻。 4) xdebug 日志中关于这次不成功尝试的内容(确保清楚/只有此请求详细信息) -
一些手册——可能有用:confluence.jetbrains.com/display/PhpStorm/…(不是 docker 特定的——只是一般的 CLI 调试)
-
是的,我遵循了这个指南。我在根公用文件夹中尝试了一个非常简单的 echo 脚本......再次......在 HTTP 中运行良好,但在 CLI 中运行良好。这是我的 phpstorm 服务器设置屏幕prntscr.com/8pgsqt
标签: php docker phpstorm xdebug