使用 Vim 进行 Xdebug 配置

Ano*_*p D 1 php vim xdebug

我在 Ubuntu 20.04 上使用 php 7.4.18 和 apache,其文档根位于/var/www/html. 这是我的 php --version

PHP 7.4.18 (cli) (built: May  3 2021 11:27:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.18, Copyright (c), by Zend Technologies
    with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)

我的 xdebug.ini

zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_mode = req
xdebug.remote_port = 9000
Run Code Online (Sandbox Code Playgroud)

我的.vimrc

let g:vdebug_options = {"port": 9000, "break-on-open": 0, }
Run Code Online (Sandbox Code Playgroud)

我安装了一个 wordpress /var/www/html/wordress ,当我尝试在 vim 中调试时,它显示“Vdebug 将等待连接”,即使我使用?XDEBUG_SESSION_START=1(我尝试为 chrome 安装 Xdebug Helper)访问“localhost/wordpress”,它也没有连接。

我还尝试过哪些其他事情

  1. 我将 xdebug.ini 代码添加到 php.ini 但无法连接它。
  2. 添加"path_maps": {'/':'/var/www/html'}到 vimrc 中的 vdebut_option 中。

请帮助并让我知道我做错了什么?

这是我的 xdebug_info() 屏幕截图 在此输入图像描述

Der*_*ick 5

您正在设置 Xdebug 2 设置,但运行 Xdebug 3:

xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_mode = req
xdebug.remote_port = 9000
Run Code Online (Sandbox Code Playgroud)

您需要根据升级指南将这些设置转换为 Xdebug 3 设置。您共享的输出xdebug_info()也链接到“文档”(最右列),并且显示“单步调试器”未启用。

  • 将设置更改为“xdebug.mode=debug xdebug.start_with_request=yes”,正如 Derick 所说,如果其他人遇到问题,请阅读升级指南。 (2认同)