Xdebug停止在Windows10上进行PHP跟踪



我对PHP和Xdebug完全陌生。我已经在Windows 10上安装了XAMPP,并且我有一个在PHP上运行的应用程序。

所以我想在Visual Studio代码上跟踪应用程序以了解它,我使用了Xdebug。我做了以下事情:

  1. 我下载了相应的php-xdebug.dll(根据php版本,在xdebug.org/wizard上(,并将其放在XAMPP的php目录中。

  2. 我安装了PHP调试扩展并添加了以下行:

    xdebug.mode = debug
    xdebug.start_with_request = yes
    xdebug.client_port = 9000
    
  3. 将此行添加到json:

    "runtimeExecutable": "C:\Xampp\PHP\php.exe"
    
  4. 在XAMPP中重新启动Apache服务。

现在我启动了应用程序,并放置了一些断点来跟踪应用程序。它工作了大约4或5个小时,没有任何问题。但在那之后它就停止工作了。

当我放置断点时,它就进入了断点。当我按下";压入";按钮,什么也没发生,Xdebug似乎不工作。

如何检查Wdebug的问题?


编辑:

这就是我的发现。这是一个非常简单的代码,我想跟踪:

<?php
$a=100;
$b=200;
echo $a."<br/>";
echo $b."<br/>";
echo $a+$b;

如果我把Xdebug放在htdocs的根目录中,Xdebug就不能再工作了,但如果我把它放在htdocs的子目录中,那么调试就可以正常工作。

这是Xdebug日志文件中的结果:

[8668] Log opened at 2262-04-09 09:08:59.927045
[8668] [Step Debug] INFO: Connecting to configured address/port: localhost:9000.
[8668] [Step Debug] INFO: Connected to debugging client: localhost:9000 (through xdebug.client_host/xdebug.client_port). :-)
[8668] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/htdocs/index.php" language="PHP" xdebug:language_version="7.2.34" protocol_version="1.0" appid="8668"><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>
[8668] [Step Debug] <- breakpoint_list -i 1
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[8668] [Step Debug] <- breakpoint_list -i 2
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>
[8668] [Step Debug] <- breakpoint_list -i 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"></response>
[8668] [Step Debug] <- breakpoint_list -i 4
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"></response>
[8668] [Step Debug] <- breakpoint_list -i 5
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"></response>
[8668] [Step Debug] <- breakpoint_list -i 6
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"></response>
[8668] [Step Debug] <- breakpoint_set -i 7 -t line -f file:///c:/xampp/htdocs/test/1.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="86680001"></response>
[8668] [Step Debug] <- breakpoint_set -i 8 -t line -f file:///c:/xampp/htdocs/1.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="86680002"></response>
[8668] [Step Debug] <- breakpoint_set -i 9 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addline.php -n 16
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="86680003"></response>
[8668] [Step Debug] <- breakpoint_set -i 10 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addorderstation.php -n 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="86680004"></response>
[8668] [Step Debug] <- breakpoint_set -i 11 -t line -f file:///c:/xampp/htdocs/app/hmi/API/addstation.php -n 14
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="86680005"></response>
[8668] [Step Debug] <- breakpoint_set -i 12 -t line -f file:///c:/xampp/htdocs/index.php -n 3
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="86680006"></response>
[8668] [Step Debug] <- breakpoint_set -i 13 -t line -f file:///c:/xampp/htdocs/index.php -n 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="86680007"></response>
[8668] [Step Debug] <- breakpoint_list -i 14
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="14"><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addstation.php" lineno="14" state="enabled" hit_count="0" hit_value="0" id="86680005"></breakpoint><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addorderstation.php" lineno="17" state="enabled" hit_count="0" hit_value="0" id="86680004"></breakpoint><breakpoint type="line" filena
[8668] [Step Debug] <- breakpoint_list -i 15
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="15"><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addstation.php" lineno="14" state="enabled" hit_count="0" hit_value="0" id="86680005"></breakpoint><breakpoint type="line" filename="file:///C:/xampp/htdocs/app/hmi/API/addorderstation.php" lineno="17" state="enabled" hit_count="0" hit_value="0" id="86680004"></breakpoint><breakpoint type="line" filena
[8668] [Step Debug] <- breakpoint_set -i 16 -t exception -x *
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="16" id="86680008"></response>
[8668] [Step Debug] <- run -i 17
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="break" reason="ok"><xdebug:message filename="file:///C:/xampp/htdocs/index.php" lineno="3"></xdebug:message></response>
[8668] [Step Debug] <- stack_get -i 18
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="18"><stack where="{main}" level="0" type="file" filename="file:///C:/xampp/htdocs/index.php" lineno="3"></stack></response>
[8668] [Step Debug] <- eval -i 19 -- KCRh
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="19" status="break" reason="ok"><error code="206"><message><![CDATA[error evaluating code]]></message></error></response>
[8668] [Step Debug] <- eval -i 20 -- Y2hyKCRhKQ==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="20"><property type="string" size="1" encoding="base64"><![CDATA[AA==]]></property></response>
[8668] [Step Debug] <- eval -i 21 -- JGE=
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="21"><property type="null"></property></response>
[8668] [Step Debug] <- eval -i 22 -- JF9SRVFVRVNUWydQQVJBTVMnXQ==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="22"><property type="null"></property></response>
[8668] [Step Debug] <- eval -i 23 -- JHBhcmFtcw==
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="23"><property type="null"></property></response>
[8668] [Step Debug] <- context_names -i 24 -d 0
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="24"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>
[8668] [Step Debug] <- context_get -i 25 -d 0 -c 0
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="25" context="0"><property name="$a" fullname="$a" type="uninitialized"></property><property name="$b" fullname="$b" type="uninitialized"></property></response>
[8668] [Step Debug] <- step_over -i 26
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="26" status="stopping" reason="ok"></response>
[8668] [Step Debug] <- stop -i 27
[8668] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="27" status="stopped" reason="ok"></response>
[8668] Log closed at 2262-04-09 09:08:59.927045

您可以通过使用php.ini设置xdebug.log=c:tempxdebug.log创建日志来检查Xdebug的功能——如果web服务器或php无法写入,则可能需要更改路径。该日志将列出所有调试连接尝试,列出潜在的连接问题,如果建立了连接,还将列出通信。您可以检查<init标记的fileuriXML属性是否与IDE应该发送的breakpoint_set命令设置的内容相匹配。

我唯一能做的就是将网站文件夹从htdocs更改为htdocs/Projects。之后一切都很顺利。我找不到的原因

最新更新