Skip to content

Instantly share code, notes, and snippets.

@andresjesse
Last active December 9, 2022 17:46
Show Gist options
  • Save andresjesse/e6a5dc2b397442743f42631e50b82612 to your computer and use it in GitHub Desktop.
Save andresjesse/e6a5dc2b397442743f42631e50b82612 to your computer and use it in GitHub Desktop.

Laravel Config for VSCode

Install portable VSCode

Download tar.gz version from https://code.visualstudio.com/download

Unpack, create an empty data folder in vscode root

Optionally, create the pcode command to open it from terminal without conficting with other vscode installation (run on vscode root):

$ sudo ln -s $(pwd)/bin/code /usr/local/bin/pcode

Configure global php command to use sail php

This step is required if you don't have php installed outside docker/sail and will override it if you have!:

$ sudo nano /usr/local/bin/php

add:

path=$(printf '%s\n' "${PWD##*/}")
command="./vendor/bin/sail php "$@""
echo "Running php on sail..."
$command

$ sudo chmod +x /usr/local/bin/php

Install material icons and dracula theme plugin:

https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme

https://marketplace.visualstudio.com/items?itemName=dracula-theme.theme-dracula

Install laravel snippets plugin:

https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel5-snippets

Install laravel artisan plugin (sail config in settings.json):

https://marketplace.visualstudio.com/items?itemName=ryannaddy.laravel-artisan

Install and configure intelephsense plugin (check plugin docs for updated guide):

https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

Install and configure Laravel IDE helper (commands adapted for sail):

https://marketplace.visualstudio.com/items?itemName=georgykurian.laravel-ide-helper

$ sail composer require --dev barryvdh/laravel-ide-helper

$ sail artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config

Configure settings.json

{
    "workbench.iconTheme": "material-icon-theme",
    "workbench.colorTheme": "Dracula",
    "artisan.docker.enabled": true,
    "artisan.docker.command": "./vendor/bin/sail",
    "intelephense.files.associations": [
        "*.php",
        "*.phtml"
    ],
    "files.associations": {
        "*.module": "php"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment