【问题标题】:Source files not found on Visual Studio Code PHP Debug (WSL server)在 Visual Studio Code PHP 调试(WSL 服务器)上找不到源文件
【发布时间】:2019-05-10 13:33:04
【问题描述】:

我在 Windows 10 上托管我的网站的本地副本,而服务器在 WSL Linux bash 上运行。我已经安装了 Visual Studio Code,并进行了 PHP 调试,配置了 Xdebug,并且从 chrome 页面成功触发了调试。但是,VS 代码然后告诉我它“无法打开”我的 php 文件。我在 json 配置文件中尝试了各种 pathMappings,但似乎没有任何效果。

有人可以帮我吗?提前非常感谢!

我的设置:

本地网站位置:D:/local_websites/ 来自linux服务器的对应路径:/mnt/d/local_websites/

xdebug.ini:

zend_extension=xdebug.so
xdebug.show_error_trace = 1
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_autostart = 1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_log="/var/log/xdebug/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
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000,
        "pathMappings": {
            "/mnt/d/": "d:/",
        }
    }
]
}

【问题讨论】:

    标签: php visual-studio-code xdebug windows-subsystem-for-linux


    【解决方案1】:

    我解决了这个在远程打开工作区的错误:

    • 在 vscode 中安装“Remote - WSL”扩展。
    • 在 WSL 中,转到您的工作区路径并输入:“code”。 (或“code /mnt/d/local_websites/”)并且会出现一个 vscode 远程实例。
    • 在这个远程 vscode 实例中,转到扩展并在您需要的扩展(PHP 调试、PHP Intelephense 等)上使用“在 WSL 上安装”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-31
      • 2023-03-10
      • 2013-07-21
      • 2016-07-12
      • 2021-06-05
      • 2022-08-06
      相关资源
      最近更新 更多