使用 VSCode 进行 Laravel 开发

上视频地址(免费的):https://laracasts.com/series/visual-studio...

1,先安装所有的扩展

  • 将下面的扩展全部安装完

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

https://marketplace.visualstudio.com/items...

2.个人设置

- code-首选项-设置 或者 command+(逗号键) 将以下内容复制到右边的一栏

{
    "editor.fontSize": 15,
    "workbench.colorTheme": "Material Theme",
    "workbench.statusBar.visible": false,
    "explorer.openEditors.visible": 0,
    "workbench.activityBar.visible": false,
    "editor.minimap.enabled": false,
    "terminal.integrated.fontSize": 14,
    "terminal.integrated.fontFamily": "Menlo, Monaco, 'Courier New', monospace",
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 3000,
    // File extensions to be parsed by the Typescript parser
    "importCost.typescriptExtensions": [
        "\\.vue$"
    ],
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "vue",
        "vue-html"
    ],
    "workbench.iconTheme": "eq-material-theme-icons",
    "editor.tabCompletion": true,
    "emmet.includeLanguages": {
        "vue-html": "html",
        "vue": "html"
    },
    "emmet.showExpandedAbbreviation": "always",
    "emmet.triggerExpansionOnTab": true
}

file

3.自定义快捷键设置

code-首选项-键盘快捷方式
file
打开这个json文件
复制如下内容

[
    {
        "key": "cmd+r",
        "command": "workbench.action.gotoSymbol"
    },
    {
        "key": "shift+cmd+o",
        "command": "-workbench.action.gotoSymbol"
    },
    {
        "key": "shift+cmd+r",
        "command": "workbench.action.showAllSymbols"
    },
    {
        "key": "cmd+t",
        "command": "-workbench.action.showAllSymbols"
    },
    {
        "key": "alt+enter",
        "command": "editor.action.showContextMenu",
        "when": "editorTextFocus"
    },
    {
        "key": "shift+f10",
        "command": "-editor.action.showContextMenu",
        "when": "editorTextFocus"
    }
]

file

4.添加ESLint

组合件 shift+command+p,输入 eslint,如图选项Enter
file
打开Eslint文件
复制以下内容

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"

    ],
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "sourceType": "module"
    },
    "rules": {
        "no-const-assign": "warn",
        "no-this-before-super": "warn",
        "no-undef": "warn",
        "no-unreachable": "warn",
        "no-unused-vars": "warn",
        "constructor-super": "warn",
        "valid-typeof": "warn"
    }
}

file

5.用户自定义代码片段

code-首选项-用户代码片段-PHP
复制以下内容

{
    "Public function": {
        "prefix": "pubf",
        "body": [
            "public function $1($2)",
            "{",
            "\t$0",
            "}"
        ],
        "description": "Public function"
    },
    "Private function": {
        "prefix": "prif",
        "body": [
            "private function $1($2)",
            "{",
            "\t$0",
            "}"
        ],
        "description": "Private function"
    },
    "Protected function": {
        "prefix": "prof",
        "body": [
            "protected function $1($2)",
            "{",
            "\t$0",
            "}"
        ],
        "description": "Protected function"
    }
}

6.(可选)配置Material Theme主题

个人gist:
https://gist.github.com/wowiwj/7cb83c1938f...

7.使用,有空慢慢更新...,慢慢补上

本作品采用《CC 协议》,转载必须注明作者和本文链接
本帖由系统于 6年前 自动加精
王举
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 22
jcc123

用过一次,止于配置。所幸这篇文章,又一次唤醒了,懒癌的我。。

6年前 评论

这个感觉前端的插件更多

6年前 评论

为什么不用phpstorm呢 喜欢折腾,为什么不用vim呢:wink:

6年前 评论
王举

@jc91715 哈哈,我也是看Jeffery的视频感觉贼6才跟着搞的

6年前 评论
王举

@BradStev 所以用这个全栈开发起来很爽啊:smile:

6年前 评论
王举

@839891627 解决了ps在npm run watch的时候卡死的痛点:ghost:

6年前 评论
颜⑧

@王举npm run watch-pollnpm run watch 好很多 不会卡。另外vscode 你用多久写php,之前我也用了,没有坚持下去。主要2点,一,快捷键 太习惯phpstorm , 二,有一次写js的时候,vscode提示问题,比如他提示 btag,但是实际上是 Btag,不知道为啥大小写有问题,不敢用了。

6年前 评论
王举

@颜⑧ 我也没多久,适应中哈哈,两个一起用最好:yum:

6年前 评论
Kurisu

开头的一排插件地址很有视觉冲击力.....:joy:

6年前 评论

watch的时候,是在 reindex, 我把 public 目录 exclude了,就不建索引了。。

6年前 评论
王举

@839891627 可以可以

6年前 评论

目前是 PhpStorm, WebStorm, VS Code 配合用,已经忘了上一次打开 Sublime Text 是什么时候了。

6年前 评论
leo

从没遇到过 phpstorm 在 npm run watch 卡死的情况

6年前 评论
王举

@leo 17.2.4好像好多了

6年前 评论
ibucoin

哈哈,是Jeffrey,我还以为我打错了。之前看他sublime text3的视频,也是一顿操作,后面还是换回了phpstorm,主要是新手开发,还是这个方便,等熟练了,就可以随意换了。

6年前 评论
王举

@ibucoin 失误失误.马上改正,我现在就是两个一起用:stuck_out_tongue: ,那个方便就用那个干

6年前 评论

玩了几天的 vs code,折腾各种配置,自动 ESlint fix,自动 php cs fixer, 用了下最后还是放弃了,在 PhpStorm 上用惯了 ide_helper,没了这玩意儿敲代码都没那么爽了。

6年前 评论

vscode 大法好,自己选择扩展,又快又好用。ps我电脑压根带不起

5年前 评论
萧宇宸

请问一下模板文件.blade.php文件如何可以自动格式化呢?

5年前 评论

请问使用vscode如何自动提示app()注册类里面的函数呢?

5年前 评论

还有@propperty 注解的模型属性也提示不了

5年前 评论

vscode好用嘛,最近想用用看

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!