簡體   English   中英

在 Visual Studio Code PHP 調試(WSL 服務器)上找不到源文件

[英]Source files not found on Visual Studio Code PHP Debug (WSL server)

我在 Windows 10 上托管我網站的本地副本,而服務器在 WSL Linux bash 上運行。 我已經安裝了 Visual Studio Code 和 PHP 調試,配置了 Xdebug,並且調試是從 chrome 頁面成功觸發的。 但是,VS 代碼然后告訴我它“無法打開”我的 php 文件。 我在 json 配置文件中嘗試了各種路徑映射,但似乎沒有任何效果。

有人可以幫我嗎? 非常感謝!

我的設置 :

本地網站位置: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"

啟動.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:/",
        }
    }
]
}

我解決了這個在遠程打開工作區的錯誤:

  • 在 vscode 中安裝“Remote - WSL”擴展。
  • 在 WSL 中,轉到您的工作區路徑並輸入:“code”。 (或“code /mnt/d/local_websites/”)並會出現一個 vscode 遠程實例。
  • 在這個遠程 vscode 實例中,轉到擴展並在您需要的擴展(PHP 調試、PHP Intelephense 等)上使用“在 WSL 上安裝”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM