我正在尝试将xdebug与visual studio代码一起使用。
但什么都没解决安装并启用了xdebug和I am a visual Studio代码扩展PHP debug。请查看下面的设置,如果我做错了什么,请指导我。
php.ini设置
[xDebug]
zend_extension="C:\laragon\bin\php\php-8.0.24-Win32-vs16-x64\ext\php_xdebug.dll"
xdebug.mode=debug
xdebug.start_with_request=Yes
;xdebug.client_port=80
;xdebug.remote_port=80
xdebug.log="C:\laragon\debug.log"
xdebug.log_level=7
xdebug.idekey=VSCODE
xdebug.client_host="mysite.test"
字符串
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 80,
"pathMappings": {
"C:/laragon/www/adamjee": "${workspaceFolder}",
},
"ignore": [
"**/vendor/**/*.php"
]
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
型
}
请指导我哪里做错了。
xdebug日志
[14160] Log opened at 2023-07-27 12:26:08.027714
[14160] [Step Debug] INFO: Connecting to configured address/port: adamjee.test:80.
[14160] [Step Debug] INFO: Connected to debugging client: adamjee.test:80 (through xdebug.client_host/xdebug.client_port).
[14160] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/laragon/www/adamjee/index.php" language="PHP" xdebug:language_version="8.0.24" protocol_version="1.0" appid="14160" idekey="VSCODE"><engine version="3.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>
[14160] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[13228] Log opened at 2023-07-27 12:26:09.225547
[13228] [Step Debug] INFO: Connecting to configured address/port: adamjee.test:80.
[14160] Log closed at 2023-07-27 12:26:09.226357
[13228] [Step Debug] INFO: Connected to debugging client: adamjee.test:80 (through xdebug.client_host/xdebug.client_port).
[13228] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/laragon/www/adamjee/index.php" language="PHP" xdebug:language_version="8.0.24" protocol_version="1.0" appid="13228" idekey="VSCODE"><engine version="3.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>
[13228] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[13228] Log closed at 2023-07-27 12:26:13.534187
[13228] Log opened at 2023-07-27 12:26:13.661112
[13228] [Step Debug] INFO: Connecting to configured address/port: adamjee.test:80.
[13228] [Step Debug] INFO: Connected to debugging client: adamjee.test:80 (through xdebug.client_host/xdebug.client_port).
[13228] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/laragon/www/adamjee/index.php" language="PHP" xdebug:language_version="8.0.24" protocol_version="1.0" appid="13228" idekey="VSCODE"><engine version="3.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>
[13228] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[13228] Log closed at 2023-07-27 12:26:15.526825
[13228] Log opened at 2023-07-27 12:26:15.544789
[13228] [Step Debug] INFO: Connecting to configured address/port: adamjee.test:80.
[13228] [Step Debug] INFO: Connected to debugging client: adamjee.test:80 (through xdebug.client_host/xdebug.client_port).
[13228] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/laragon/www/adamjee/index.php" language="PHP" xdebug:language_version="8.0.24" protocol_version="1.0" appid="13228" idekey="VSCODE"><engine version="3.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>
[13228] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[13228] Log closed at 2023-07-27 12:26:16.975555
型
1条答案
按热度按时间2hh7jdfx1#
php.ini
配置中的以下位:字符串
在
launch.json
中:型
都是错的。把它们拿开。
Xdebug需要连接到IDE正在侦听的端口。默认值为9003,这也是VS Code的默认值。请从您的配置中删除此行。
现在,您正在指示Xdebug连接到端口80(您的日志表明它正在这样做):
型
但是你的web服务器在那里监听,你的web服务器不理解Xdebug协议,因此在两秒钟的困惑之后关闭了连接:
型