【问题标题】:xdebug phpstorm docker linuxxdebug phpstorm docker linux
【发布时间】:2020-02-14 13:41:38
【问题描述】:

我无法通过 xdebug 捕获对我的应用程序的任何请求。

xdebug.ini

zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_enable=On

【问题讨论】:

标签: linux docker phpstorm xdebug


【解决方案1】:

我看到您已将其标记为“docker”。如果使用 docker,则不能使用xdebug.remote_connect_back=1。您需要指定xdebug.remote_host=IP-address-of-the-machine-as-reachable-by-docker-where-your-IDE-runs。这个可以在较新的版本中是host.docker.internal

为了进一步调试网络问题,还请在您的php.ini 设置中设置xdebug.remote_log=/tmp/xdebug.log,并在您启动调试会话(通过浏览器扩展程序)时查看它的内容。

【讨论】:

  • 我按照你的说法指定了远程主机,但执行仍然没有在刹车点停止。我将日志记录添加到 xdebug。这是输出:[32365] Log opened at 2020-02-18 13:49:03 [32365] I: Connecting to configured address/port: 0.0.0.0:9000. [32365] I: Connected to client. :-) xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"> </response>
  • 所以我立即进入停止状态,没有任何中断/启动/运行/停止
  • <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///app/artisan" language="PHP" xdebug:language_version="7.2.19" protocol_version="1.0" appid="14781" idekey="PHPSTORM"><engine version="2.9.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
  • 看起来在 Xdebug 方面一切正常,你的问题出在你的 IDE 上。
  • 我通过sudo iptables -A INPUT -p tcp --dport 9000 -j ACCEPT 修复了它,现在它可以工作了
【解决方案2】:

sudo iptables -A INPUT -p tcp --dport 9000 -j ACCEPT修复 使用以下 xdebug.ini 配置

xdebug.remote_autostart = 1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=0
#172.17.0.1 is docker0 interface ip address (see ifconfig)
xdebug.remote_host=172.17.0.1
xdebug.remote_enable=On
xdebug.remote_port=9000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-07
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 2020-02-19
    • 2018-04-27
    • 1970-01-01
    相关资源
    最近更新 更多