Xdebug 未在断点处停止

huangapple go评论73阅读模式
英文:

Xdebug not stopping at breakpoints

问题

Xdebug在断点处不停止。

我尝试了不同版本的Xdebug(当前版本为v1.32.1、v1.32.0、v1.31.1、v1.31.0、v1.30.0)。

这是我的launch.json文件中的配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "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"
            }
        }
    ]
}

是否可能与Web服务器冲突?

这是我的php.ini文件中的配置(位于文件底部):

[xdebug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003        // 即使没有这一行也不起作用。

安装向导

从 <https://xdebug.org/wizard> 的摘要

• Xdebug已安装:3.2.1
• 服务器API:Apache 2.0处理程序
• Windows:是的
• 编译器:MS VS16
• 架构:x64
• Zend服务器:否
• PHP版本:8.2.4
• Zend API编号:420220829
• PHP API编号:20220829
• 调试构建:否
• 线程安全构建:是
• OPcache已加载:否
• 配置文件路径:无值
• 配置文件:C:\xampp\php\php.ini
• 扩展目录:C:\xampp\php\ext

我已从向导中下载了文件并正确重命名。

根据文档,端口9003是正确的。但我也尝试了端口9000。

如果我前往https://portchecker.co/checking并检查端口9000或9003,它们都是关闭的。

  • 我重新安装了XAMPP
  • 我重新安装了VS Code

我还前往设置 -> 功能 -> 调试 -> 允许处处断点

英文:

Xdebug does not stop at breakpoints.

I tried different versions of Xdebug. (current v1.32.1, v1.32.0, v1.31.1, v1.31.0, v1.30.0)

This is my configuration at the launch.json file:

{
// 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
&quot;version&quot;: &quot;0.2.0&quot;,
&quot;configurations&quot;: [
    {
        &quot;name&quot;: &quot;Listen for Xdebug&quot;,
        &quot;type&quot;: &quot;php&quot;,
        &quot;request&quot;: &quot;launch&quot;,
        &quot;port&quot;: 9003
    },
    {
        &quot;name&quot;: &quot;Launch currently open script&quot;,
        &quot;type&quot;: &quot;php&quot;,
        &quot;request&quot;: &quot;launch&quot;,
        &quot;program&quot;: &quot;${file}&quot;,
        &quot;cwd&quot;: &quot;${fileDirname}&quot;,
        &quot;port&quot;: 0,
        &quot;runtimeArgs&quot;: [
            &quot;-dxdebug.start_with_request=yes&quot;
        ],
        &quot;env&quot;: {
            &quot;XDEBUG_MODE&quot;: &quot;debug,develop&quot;,
            &quot;XDEBUG_CONFIG&quot;: &quot;client_port=${port}&quot;
        }
    },
    {
        &quot;name&quot;: &quot;Launch Built-in web server&quot;,
        &quot;type&quot;: &quot;php&quot;,
        &quot;request&quot;: &quot;launch&quot;,
        &quot;runtimeArgs&quot;: [
            &quot;-dxdebug.mode=debug&quot;,
            &quot;-dxdebug.start_with_request=yes&quot;,
            &quot;-S&quot;,
            &quot;localhost:0&quot;
        ],
        &quot;program&quot;: &quot;&quot;,
        &quot;cwd&quot;: &quot;${workspaceRoot}&quot;,
        &quot;port&quot;: 9003,
        &quot;serverReadyAction&quot;: {
            &quot;pattern&quot;: &quot;Development Server \\(http://localhost:([0-9]+)\\) started&quot;,
            &quot;uriFormat&quot;: &quot;http://localhost:%s&quot;,
            &quot;action&quot;: &quot;openExternally&quot;
        }
    }
]}

Could there be a conflict with the web server?

This is my configuration in the php.ini (all the way at the bottom of the file):

[xdebug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003        // it also doesnt work without this line.

Installation Wizard

Summary from &lt;https://xdebug.org/wizard&gt; 
• Xdebug installed: 3.2.1
• Server API: Apache 2.0 Handler
• Windows: yes 
• Compiler: MS VS16
• Architecture: x64
• Zend Server: no 
• PHP Version: 8.2.4
• Zend API nr: 420220829
• PHP API nr: 20220829
• Debug Build: no
• Thread Safe Build: yes
• OPcache Loaded: no
• Configuration File Path: no value
• Configuration File: C:\xampp\php\php.ini
• Extensions directory: C:\xampp\php\ext

Xdebug 未在断点处停止

Xdebug 未在断点处停止

Xdebug 未在断点处停止

Xdebug 未在断点处停止

I've downloaded the file from the wizard and renamed it correctly.

Port 9003 is correct according to the documentation. But I also tried port 9000 as well.

If I go to https://portchecker.co/checking and check for Port 9000 or 9003 they are closed.

  • I reinstalled XAMPP
  • I reinstalled VS Code

I also went to Settings -&gt; Features -&gt; Debug -&gt; Allow Breakpoints Everywhere.

答案1

得分: 2

我已经安装了xampp和xdebug。

我们的launch.json文件和向导输出是相同的,似乎对我来说可以工作。

我的php.ini文件没有包含最后一行的端口号,也没有包含你所拥有的xdebug闭合括号后的撇号。

[xDebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes

考虑到已经为您映射了扩展目录,您不应该需要整个文件路径来定义您的zend_extension。

我建议您再次检查您在vscode设置中是否定义了"php.debug.executablePath"

在运行vscode中的Listen for Xdebug后,我的设置如下:

  1. 运行 Listen for Xdebug 在 vscode 中
  2. 在浏览器中导航到我在这里使用的文件 http://localhost/info/index.php

Xdebug 未在断点处停止

如果进行这些更改后仍然不起作用,也许可以再次确认断点是否真的可以到达。

英文:

I went ahead and installed xampp and xdebug.

Our launch.json files and wizard output are identical and it seems to work ok for me.

My php.ini doesn't include the last line with the port number or the apostrophe after the xdebug closing brace that you have.

[xDebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes

You shouldn't need the entire file path for your zend_extension considering that the extensions directory is already mapped for you.

I would double check that you've defined your &quot;php.debug.executablePath&quot;: in vscode settings as well.

Here's what mine looks like after

  1. Running Listen for Xdebug in vscode
  2. Navigating to the file I used here at http://localhost/info/index.php in the browser

Xdebug 未在断点处停止

If making those changes still doesn't work, maybe double check that the breakpoint is actually reachable.

huangapple
  • 本文由 发表于 2023年6月2日 03:01:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定