xdebug 使用 laravel 时根本没有中断控制器

问题描述 投票:0回答:1

我正在尝试将 xdebug 与 Visual Studio 代码一起使用。

但没有任何结果。 安装并启用 xdebug,我是 Visual Studio 代码扩展 PHP 调试。 请检查下面的设置,如果我做错了什么,请指导我。

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"

启动.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"
        }
    }
]

}

请指导我哪里做错了。

x调试日志

    [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
php laravel xdebug
1个回答
0
投票

您的

php.ini
配置中的以下部分:

;xdebug.client_port=80
;xdebug.remote_port=80

并在你的

launch.json
中:

"port": 80,`

两者都错了。删除它们。


Xdebug 需要连接到您的 IDE 正在侦听的端口。默认情况下为 9003,这也是 VS Code 的默认值。请从您的配置中删除此行。

现在,您正在指示 Xdebug 连接到端口 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>

但是那是你的 web 服务器在那里监听,而你的 web 服务器不理解 Xdebug 协议,因此在困惑两秒后关闭连接:

[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
© www.soinside.com 2019 - 2024. All rights reserved.