VS CODE 配置 live server 和 Open PHP/HTML/JS In Browser 和PHP debug 及 javascript debugger 和launch.json 及

VS CODE 配置 live server 和 Open PHP/HTML/JS In Browser 和PHP debug 及 javascript debugger 和launch.json 及settings.josn 实现了 非常方便的 HTML 和PHP 及 JS 实时调试。文件如下。

安装的插件如下:全都需要装,不要少

 

调试HTML用live server  实时显示调试。调试HTML 内外链的JS 时,要先启用live server 再 用"F5 JS HTML Launch Chrome against localhost 后,直接按 F5打开chrom.

先配置PHP 调试环境

    "php.validate.executablePath":"D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\php.exe",
    "php.debug.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\ext\\php_xdebug.dll",

再配置  code-runner 支持PHP和html 用360以绝对路径打开。

    "code-runner.executorMap": {
        "php": "D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\php.exe",
        "html": "\"C:\\Users\\Administrator\\AppData\\Roaming\\360se6\\Application\\360se.exe\"",

open-php-html-js-in-browser 的配置。用Chrom以localhost网址打开。

    "open-php-html-js-in-browser.documentRootFolder": "D:/phpstudy_pro/WWW/",
    "open-php-html-js-in-browser.selectedBrowser": "Chrome",

liveServer的配置关键点 

    "liveServer.settings.host": "localhost",
    "liveServer.settings.CustomBrowser": "chrome",

 

各自的界面 设置 

liveserver 工作区 主要设置  localhost 和chrome

 open-php-html-js-in-browser主要设置,打开URL 和本地绝对路径及打开浏览器为Chrome

 

settings.json 配置文件如下。

{
    "php.validate.executablePath":"D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\php.exe",
    "php.debug.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\ext\\php_xdebug.dll",
    "code-runner.saveFileBeforeRun": true,
    "code-runner.executorMap": {
        "php": "D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\php.exe",
        "html": "\"C:\\Users\\Administrator\\AppData\\Roaming\\360se6\\Application\\360se.exe\"",
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      //  "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "sml": "cd $dir && sml $fileName"
    },
    "open-php-html-js-in-browser.documentRootFolder": "D:/phpstudy_pro/WWW/",
    "open-php-html-js-in-browser.selectedBrowser": "Chrome",
    "editor.renderWhitespace": "all",
    "editor.unicodeHighlight.ambiguousCharacters": false,
    "debug.javascript.autoAttachFilter": "always",
    "liveServer.settings.host": "localhost",
    "liveServer.settings.CustomBrowser": "chrome",


}

launch.json 文件 配置了三种方式的调试 node.js 在VS输入调试。PHP的 debug 和 F5键直接调试HTML外链的JS   端口号要设置的跟live server一致。

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch JS Program",
            "program": "${workspaceFolder}/${relativeFileDirname}/${fileBasename}",
            "request": "launch",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        },

        {
            "name": "监听 Xdebug open PHP",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "type": "chrome",
            "request": "launch",
            "name": "F5 JS HTML Launch Chrome against localhost",
            "url": "http://localhost:5500/${relativeFileDirname}/${fileBasename}",
            "webRoot": "${workspaceFolder}"
        },

    ]
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值