VSCode IDE Setup

Setting up the Visual Studio Code editor to work well with Drupal

Add XDebug

  1. Edit .vscode/launch.json

  2. Add the following configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
              "/app/": "${workspaceRoot}/",
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

Add Drupal coding standards

  1. Click in top navbar navigate to file > preferences > settings

  2. Under Workspace Settings expand the Extensions option

  3. Locate PHP CodeSniffer configuration and scroll down to the Standard section and click the "Edit in settings.json" link

  4. Add the following configuration to your Workspace Settings:

{
    "phpcs.standard": "vendor/drupal/coder/coder_sniffer/Drupal",
}

Last updated