簡體   English   中英

無法在vscode中逐行調試php

[英]Cannot debug php line by line in vscode

鑒於我的 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 配置位於WSL2 Ubuntu-20.04中的/etc/php/8.0/mods-available/中,遵循此處的設置

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

但是在 php 代碼上添加斷點並按f5 ,然后在 chrome 中訪問本地 php 項目,什么也沒發生。

我確實也閱讀了以下內容

使用 xdebug 設置 VSCode:pathMapping

VSCode - XDebug 連接到客戶端但斷點不起作用

但似乎對我的情況不起作用。

你知道為什么嗎?

以前很好,但現在不行

剛剛自己找到了答案。 在 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

暫無
暫無

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

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