在 CLI 中运行文件时,PhpStorm Xdebug 在 WSL 中不起作用

问题描述

我在 WSL2 中运行 Ubuntu 20.04。我的 Xdebug 已配置并在 chrome 上浏览本地开发站点时触发 PHPStorm 断点,正如它应该的那样。

但是,当通过 CLI (PHP test.PHP) 运行 PHP 脚本时,PHPStorm 注意到连接并暂停但没有断点,我无法交互,没有任何反应。

Xdebug 设置:

zend_extension = /usr/lib/PHP/20190902/xdebug.so
xdebug.log = "/var/www/html/test.log"
xdebug.mode=debug
xdebug.client_host=172.28.192.1
xdebug.client_port=9000
;xdebug.idekey=PHPSTORM
xdebug.start_with_request=yes
xdebug.log_level = 7

尝试在 CLI 中运行脚本时 Xdebug 日志的输出

[14214] Log opened at 2021-05-15 00:41:14.790013
[14214] [Step Debug] INFO: Connecting to configured address/port: 172.28.192.1:9000.
[14214] [Step Debug] INFO: Connected to debugging client: 172.28.192.1:9000 (through xdebug.client_host/xdebug.client_port). :-)
[14214] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/dev_test/test/test.PHP" language="PHP" xdebug:language_version="7.4.3" protocol_version="1.0" appid="14214"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>

[14214] [Step Debug] <- feature_set -i 1 -n show_hidden -v 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

[14214] [Step Debug] <- feature_set -i 2 -n max_depth -v 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

[14214] [Step Debug] <- feature_set -i 3 -n max_children -v 100
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

[14214] [Step Debug] <- feature_set -i 4 -n extended_properties -v 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="extended_properties" success="1"></response>

[14214] [Step Debug] <- feature_set -i 5 -n notify_ok -v 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>

[14214] [Step Debug] <- feature_set -i 6 -n resolved_breakpoints -v 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="6" feature="resolved_breakpoints" success="1"></response>

[14214] [Step Debug] <- stdout -i 7 -c 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="7" success="1"></response>

[14214] [Step Debug] <- status -i 8
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="status" transaction_id="8" status="starting" reason="ok"></response>

[14214] [Step Debug] <- step_into -i 9
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="9" status="break" reason="ok"><xdebug:message filename="file:///var/www/dev_test/test/test.PHP" lineno="2"></xdebug:message></response>

[14214] [Step Debug] <- eval -i 10 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10"><property type="bool"><![CDATA[0]]></property></response>

[14214] [Step Debug] <- eval -i 11 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="bool"><![CDATA[0]]></property></response>

[14214] [Step Debug] <- eval -i 12 -- aXNzZXQoJF9TRVJWRVJbJ1NTSF9DT05ORUNUSU9OJ10p
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="bool"><![CDATA[0]]></property></response>

[14214] [Step Debug] <- eval -i 13 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9BRERSJ10p
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="bool"><![CDATA[0]]></property></response>

[14214] [Step Debug] <- breakpoint_set -i 14 -t line -f file:////wsl$/Ubuntu-20.04/var/www/dev_test/test/test.PHP -n 10
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="142140001" resolved="unresolved"></response>

[14214] [Step Debug] <- stack_get -i 15
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="15"><stack where="{main}" level="0" type="file" filename="file:///var/www/dev_test/test/test.PHP" lineno="2"></stack></response>

[14214] [Step Debug] <- stack_get -i 16
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="16"><stack where="{main}" level="0" type="file" filename="file:///var/www/dev_test/test/test.PHP" lineno="2"></stack></response>

[14214] [Step Debug] <- context_names -i 17
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="17"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

[14214] [Step Debug] <- eval -i 18 -- JEdMT0JBTFNbJ0lERV9FVkFMX0NBQ0hFJ11bJzJlN2M3ZjYzLTFjNDEtNDgwMS04ZDA2LWMyYzIwZGQ4MzZhNCddPSR1X29iag==
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="18"><property type="null"></property></response>

[14214] [Step Debug] <- context_get -i 19 -d 0 -c 0
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="19" context="0"><property name="$IDE_EVAL_CACHE" fullname="$IDE_EVAL_CACHE" type="array" children="1" numchildren="1" page="0" pagesize="100"><property name="2e7c7f63-1c41-4801-8d06-c2c20dd836a4" fullname="$IDE_EVAL_CACHE[&quot;2e7c7f63-1c41-4801-8d06-c2c20dd836a4&quot;]" type="null"></property></property><property name="$db" fullname="$db" type="uninitialized"></property><prope
[14214] [Step Debug] <- context_get -i 20 -d 0 -c 1
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="20" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_ENV" fullname="$_ENV" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><property name="$_FILES" fullname="$_FILES" type="array" children="0" numchildren="0" page="0" pagesize="100"></property><pro
[14214] [Step Debug] <- run -i 21
[14214] [Step Debug] -> <stream xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" type="stdout" encoding="base64"><![CDATA[CkRlYnVnIEJ1ZmZlcgo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ck1lbW9yeSBVc2FnZTogNDY3ODY0MCBCdWZmZXIgU2l6ZTogNwotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCkRFQlVHIFtMMDM5OV0gWzEzNTEybXNdOiBHTE9CQUw6IFVsstogdGVzdC5waHAgSVAgQWRkcmVzczogCkRFQlVHIFtMMDQwMF0gWzEzNTEy
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="21" status="stopping" reason="ok"></response>

[14214] [Step Debug] <- detach -i 22
[14214] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="22" status="stopping" reason="ok"></response>

[14214] Log closed at 2021-05-15 00:41:28.327542


解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)