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

在CLI中运行文件时,PhpStorm Xdebug在WSL中不工作,php,phpstorm,xdebug,windows-subsystem-for-linux,Php,Phpstorm,Xdebug,Windows Subsystem For Linux,我正在WSL2中运行Ubuntu20.04。在chrome上浏览本地开发人员站点时,我的Xdebug已经配置好并触发PhpStorm断点,正如它应该做的那样 但是,当通过CLI(PHP test.PHP)运行PHP脚本时,PhpStorm会注意到连接并停止,但没有断点,我无法交互,什么也没有发生 Xdebug设置: zend_extension = /usr/lib/php/20190902/xdebug.so xdebug.log = "/var/www/html/test.log&

我正在WSL2中运行Ubuntu20.04。在chrome上浏览本地开发人员站点时,我的Xdebug已经配置好并触发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


[14214]日志于2021-05-15 00:41:14.790013打开
[14214][步骤调试]信息:连接到配置的地址/端口:172.28.192.1:9000。
[14214][步骤调试]信息:连接到调试客户端:172.28.192.1:9000(通过xdebug.client\u主机/xdebug.client\u端口):-)
[14214][步骤调试]->
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214][步骤调试]
[14214]日志在2021-05-15 00:41:28.327542关闭

对于成功的调试会话,请显示相同的Xdebug日志(对于相同的文件/URL)。从我看到的情况来看:IDE使用
//wsl$/Ubuntu-20.04/var/www/timetrex\u test/test/test.php设置断点
路径,但是正确的路径应该没有前面的
//wsl$/Ubuntu-20.04
部分。所以我只想看看那里使用了什么路径。如果web调试的路径是正确的,那么您可能需要通过ENV设置
serverName
,以便IDE知道用于执行正确路径映射的
PHP | server
条目。如果您自己在终端中启动这样的CLI调试,而不是在IDE中使用PHP脚本类型的Run/debug配置(IDE应该涵盖这一时刻)。在常规浏览开发人员站点上更正路径为“filename=”file:///var/www“没有//wsl$。也可以更正直接在PhpStorm中使用debug运行脚本的错误。”(右键单击->文件调试)会触发断点,但不会运行(右键单击文件->运行)。我假设在运行PhpStorm的WSL或windows中设置serverName?1)“右键单击文件->运行”“它不应该触发调试。我的意思是:是的,您的Xdebug配置为尝试并调试每个请求。。。但是PhpStorm也应该为传入的调试连接做好准备。。。单击“调试”时,它将开始侦听传入的调试请求,但在使用“运行”时不会。因此,如果您想在使用Run时使用debug,还应该确保绿色的“phone handle”图标处于打开状态。很抱歉,最近Relay,该环境变量完全解决了这个问题。非常感谢。