在调试时,有时会碰壁.所有日志(log)都表明我的PHP.XDEBUG设置(运行VSCODE和带有PHP/XDEBUG的Windows服务器的客户端)应该正常工作,但它在日志(log)文件中触发了一个"致命错误",这无助于我中断问题-似乎识别了无关的断点,但我已经清除了所有内容,所以问题是有人能帮助我吗?总结如下:
- XDEBUG已生成日志(log)文件
- 它已连接到客户端计算机
- 它已经标识了本地主机项目路径
c:/Development-DEV/VSCode/Prog/phpinfo.php -n 3
- 它已经标识了断点(第3行)
以下是正在调试并部署到服务器的项目和Launch.json:
1 <?php
2
3 echo "Hello"; <- breakpoint
4 echo "world";
5
6 ?>
Launch.json文件
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"log": true,
}
以下是Windows服务器中的PHP.INI文件[XDEBUG}设置:
[XDebug]
;zend_extension = "C:\php\ext\php_xdebug-2.7.0RC1-7.3-vc15-nts-x86_64.dll"
zend_extension = "C:\php-7.4.30-nts-Win32-vc15-x64\ext\php_xdebug-3.1.5-7.4-vc15-nts-x86_64.dll"
;zend_extension = "php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.client_port=9003
xdebug.remote_handler=dbgp
xdebug.remote_connect_back = 0
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host=localhost
xdebug.discover_client_host=true
xdebug.idekey=VSCODE
xdebug.output_dir="C:\InetPub\wwwroot\logs\"
xdebug.log = 'C:\InetPub\wwwroot\logs\xdebug.log'
以下是从服务器获取的XDEBUG日志(log).
[3516] Log opened at 2022-10-07 06:47:58.635802
[3516] [Step Debug] INFO: Checking remote connect back address.
[3516] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[3516] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[3516] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 121.152.74.44:9003.
[3516] [Step Debug] WARN: Could not connect to client host discovered through HTTP headers, connecting to configured address/port: localhost:9003. :-|
[3516] [Step Debug] INFO: Connected to debugging client: 121.152.74.44:9003 (from REMOTE_ADDR HTTP header), localhost:9003 (fallback through xdebug.client_host/xdebug.client_port). :-)
[3516] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/inetpub/wwwroot/phpinfo.php" language="PHP" xdebug:language_version="7.4.30" protocol_version="1.0" appid="3516" idekey="VSCODE"><engine version="3.1.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>
[3516] [Step Debug] <- feature_set -i 1 -n max_children -v 100
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_children" success="1"></response>
[3516] [Step Debug] <- feature_set -i 2 -n max_data -v 8192
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_data" success="1"></response>
[3516] [Step Debug] <- breakpoint_set -i 3 -t line -f file:///c:/Development-DEV/VSCode/Prog/phpinfo.php -n 3
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="35160009"></response>
[3516] [Step Debug] <- breakpoint_set -i 4 -t exception -x "Fatal error"
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="35160010"></response>
[3516] [Step Debug] <- breakpoint_set -i 5 -t exception -x "Parse error"
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="35160011"></response>
[3516] [Step Debug] <- breakpoint_set -i 6 -t exception -x "Unknown error"
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="35160012"></response>
[3516] [Step Debug] <- run -i 7
[3516] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>
[3516] Log closed at 2022-10-07 06:48:00.608238