Visual Studio Code(vsCode) is a highly customizable code editor. it can be taken next level if you configure it properly for specific use cases. In this post, we’ll setup vsCode for Laravel development.
Extensions
it’s a very much required extension if you want to do PHP development in vscode. Gives you proper autocompletion, error hinting, goto type definition, provides autocompletion based on docs comments, etc. It’s also provides you with WordPress code completion but by default not enabled.
another required extension for good auto-completion. It will provide you with a better view, validation rules, ENV, configs, etc. auto-completion.
I found it good to regularly write docs for classes and functions. To get the PHPDoc Generator to generate a PHPDoc block, place the cursor on a line with a class, method, or property and press Control+Enter
.
It’ll auto-format blade files after saving.
Some essential snippets for Laravel blade files. For example, b:foreach will set foreach loop block, b:if-else will set if-else condition block. For more snippets, you may read the extension’s details.
.env
file’s syntax highlighting.
The under-rated extension helps you to run pest tests from a file, under a test scope, and globally.
My personal keyboard shortcuts for these extensions
{
"key": "alt+r",
"command": "better-pest.run"
},
{
"key": "cmd+k cmd+r",
"command": "-better-pest.run"
},
{
"key": "alt+f",
"command": "better-pest.run-file"
},
{
"key": "cmd+k cmd+f",
"command": "-better-pest.run-file"
}
JSONBelow these videos, use alt+r
to run a single test scope and entire file.
provides some snippets for quickly writing pest related common block of codes.
:pte
to access alltest()
snippets.:pti
to access allit()
snippets.:pex
to access the availableexpect()
methods.
Thanks.
Not a big fan of PHP Intelephense as PHPTools have much more PHP8+ features but anyway just a personal preference.
Also another good extension is Laravel Pint 🙂 https://marketplace.visualstudio.com/items?itemName=open-southeners.laravel-pint
Check out this entire arsenal over [here](https://github.com/GoodM4ven/lara-stacker/blob/master/files/.opinionated/extensions.md)!