首页 > 解决方案 > Visual Studio Code 调试器不会在除 index.php 之外的任何其他文件中的断点处停止

问题描述

我在 WSL 上的 php8.0 上有这个 xdebug 配置。

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_port=9000
xdebug.discover_client_host=1
xdebug.start_with_request=yes
xdebug.log=/mnt/c/www/traces/xdebug.log

在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": 9000,
            "pathMappings": {
                "/var/www/html/": "${workspaceFolder}"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

使用的扩展名

https://github.com/xdebug/vscode-php-debug/actions?query=branch:main

现在,当我在 VScode 上设置断点my-root-directory/public/index.php并在 VScode 上运行和调试并在 Google Chrome 上刷新时,它将在断点处停止。

my-root-directory/public/index.php是在浏览器上访问应用时的入口文件。

当我my-root-directory/app/controller/someController.php在 VSCode 上设置断点并运行和调试并在 Google Chrome 上刷新时。

它不会停在那里。

您是否遇到过这种情况,您的解决方案是什么?

标签: visual-studio-codephp-8xdebug-3

解决方案


推荐阅读