【问题标题】:Cannot debug php line by line in vscode无法在vscode中逐行调试php
【发布时间】:2020-12-25 15:36:13
【问题描述】:

鉴于我的 vscode 中的这个设置

{
    // 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": 9003,
            "hostname":"::1",
            "pathMappings": {
                "/var/www/html/": "${workspaceRoot}/item-street"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "hostname": "::1",
            "port": 9003
        }
    ]
}

和 xdebug.ini

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_port=9003
xdebug.discover_client_host=1

这个xdebug配置位于/etc/php/8.0/mods-available/WSL2Ubuntu-20.04 按照这里的设置

https://github.com/felixfbecker/vscode-php-debug

但是在php代码上加断点,按f5,在chrome中访问本地php项目 什么都没发生。

我确实也阅读了以下内容

Setting up VSCode with xdebug: pathMapping

VSCode - XDebug connected to client but break points does not work

但似乎不适用于我的情况。

你知道为什么吗?

以前还可以,现在不行了

【问题讨论】:

    标签: php visual-studio-code


    【解决方案1】:

    刚刚自己找到了答案。在 VSCode 上单击远程资源管理器,不确定这是否真的是其中的一部分,然后在 Google Chrome 上安装 PHP 调试器扩展。

    在PHP文件上打个断点,在chrome上点击PHP调试器,在VSCode上按f5,就可以了。

    编辑:

    我最初的陈述有效,但不是真正的答案。 实际答案是https://github.com/felixfbecker/vscode-php-debug 仅支持端口:9000 或者只是 xdebug 仅支持端口 9000。

    所以不是

    xdebug.client_port=9003
    

    设置为

    xdebug.client_port=9000
    

    【讨论】:

      猜你喜欢
      • 2021-03-10
      • 2020-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-25
      • 1970-01-01
      • 2021-11-27
      • 2021-07-22
      相关资源
      最近更新 更多