【问题标题】:Visual Studio Code is not launching a browser when debuging a PHP Application [wordpress]调试 PHP 应用程序 [wordpress] 时,Visual Studio Code 未启动浏览器
【发布时间】:2019-11-03 19:24:26
【问题描述】:

我正在运行: Ubuntu v18.04.1 Visual Studio 代码 v1.35.1 PHP v7.2.19-0ubuntu0.18.04.1 xdebug v2.7.2 wordpress v5.2.1

我正在尝试使用 Visual Studio 代码及其工作来调试 WordPress,当我通过按 F5它启动调试会话时,它会在断点处停止。

问题是vscode没有启动浏览器,而是在调试控制台中显示所有页面源,然后结束调试会话。

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,
            "program":"${workspaceRoot}/index.php",
            "pathMappings": {
                "/var/www/html/wordpress": "${workspaceRoot}"
            }

        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

感谢您阅读此问题。我会很感激任何帮助

【问题讨论】:

    标签: php wordpress visual-studio-code vscode-settings vscode-debugger


    【解决方案1】:

    第一个我不确定它是否有帮助,但我认为你的错误:

    "程序":"${workspaceRoot}/index.php",
    “路径映射”:{
    "/var/www/html/wordpress": "${workspaceRoot}" }

    你的 wordpress 文件夹在 html 文件夹内吗? html文件夹是安装apache时linux自带的默认文件夹,切换程序和pathMapping的地方怎么办?喜欢

    "pathMappings": {  
       "/var/www/html/wordpress": "${workspaceRoot}"  
    }
    "program":"${workspaceRoot}/index.php",  
    

    这可能是题外话,但我建议你使用带有 browserSync 的 gulp 非常酷 如果你用过一次,你就会永远相信我

    this link 将帮助您在 1 小时内启动它 如果你知道 gulp 可以为 wordpress 做什么,你不会后悔的 简而言之,如果您深入了解它,它会自动执行更多操作 不止于 vscode

    顺便说一句,您可以只执行 BrowserSync,其余的保留
    但最好观看整个视频,以免出错,然后根据需要进行修改

    【讨论】:

      猜你喜欢
      • 2022-08-20
      • 2022-08-11
      • 2010-10-29
      • 2018-01-28
      • 2012-04-11
      • 2017-05-01
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多