Xdebug 在 Windows 10 上停止了 PHP 跟踪
Xdebug stopped working on PHP tracing on Windows 10
我对 PHP 和 Xdebug 完全陌生。我在 Windows 10 上安装了 XAMPP 并且在 PHP.
上有一个 运行 应用程序
所以我想在 Visual Studio 代码上跟踪应用程序以了解它,我使用了 Xdebug。我做了以下事情:
我下载了合适的php-xdebug.dll(根据PHP版本,在xdebug.org/wizard上)并将其放在PHP 目录 XAMPP.
我安装了 PHP 调试扩展并添加了这些行:
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
将此行添加到 json:
"runtimeExecutable": "C:\Xampp\PHP\php.exe"
重启 Apache 服务 XAMPP。
现在我启动了应用程序并放置了一些断点来跟踪应用程序。它工作正常大约 4 或 5 小时,没有任何问题。但在那之后它就停止工作了。
当我设置断点时它进入断点。当我按下“压入”按钮时,没有任何反应,似乎 Xdebug 不工作。
我如何检查 Wdebug 有什么问题?
编辑:
这是我发现的。这是一个非常简单的代码,我想跟踪:
<?php
$a=100;
$b=200;
echo $a."<br/>";
echo $b."<br/>";
echo $a+$b;
如果我放在 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:\temp\xdebug.log
创建日志来检查 Xdebug 做了什么——如果 Web 服务器或 PHP 不能,您可能必须更改路径写信给那个。该日志将列出所有调试连接尝试,列出潜在的连接问题,如果建立了连接,还会列出通信。您可以检查 <init
标签的 fileuri
XML 属性是否与 IDE 应该发送的 breakpoint_set
命令设置的内容匹配。
我唯一能做的就是将网站文件夹从 htdocs 更改为 htdocs/Projects。之后一切正常。找不到原因
我对 PHP 和 Xdebug 完全陌生。我在 Windows 10 上安装了 XAMPP 并且在 PHP.
上有一个 运行 应用程序所以我想在 Visual Studio 代码上跟踪应用程序以了解它,我使用了 Xdebug。我做了以下事情:
我下载了合适的php-xdebug.dll(根据PHP版本,在xdebug.org/wizard上)并将其放在PHP 目录 XAMPP.
我安装了 PHP 调试扩展并添加了这些行:
xdebug.mode = debug xdebug.start_with_request = yes xdebug.client_port = 9000
将此行添加到 json:
"runtimeExecutable": "C:\Xampp\PHP\php.exe"
重启 Apache 服务 XAMPP。
现在我启动了应用程序并放置了一些断点来跟踪应用程序。它工作正常大约 4 或 5 小时,没有任何问题。但在那之后它就停止工作了。
当我设置断点时它进入断点。当我按下“压入”按钮时,没有任何反应,似乎 Xdebug 不工作。
我如何检查 Wdebug 有什么问题?
编辑:
这是我发现的。这是一个非常简单的代码,我想跟踪:
<?php
$a=100;
$b=200;
echo $a."<br/>";
echo $b."<br/>";
echo $a+$b;
如果我放在 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:\temp\xdebug.log
创建日志来检查 Xdebug 做了什么——如果 Web 服务器或 PHP 不能,您可能必须更改路径写信给那个。该日志将列出所有调试连接尝试,列出潜在的连接问题,如果建立了连接,还会列出通信。您可以检查 <init
标签的 fileuri
XML 属性是否与 IDE 应该发送的 breakpoint_set
命令设置的内容匹配。
我唯一能做的就是将网站文件夹从 htdocs 更改为 htdocs/Projects。之后一切正常。找不到原因