Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>DrupalNew to Visual Studio Code? Get it now.
Drupal

Drupal

Stanislav Romanov

|
28,509 installs
| (5) | Free
A Drupal extension for VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode Drupal

This extension supports only Drupal projects that use the Composer template drupal/recommended-project.

Features

  • syntax highlighting
  • hook completion
  • twig completion
  • service completion
  • global variables completion
  • code checking Drupal coding standards (phpcs, coder)
  • document formatting according to standards (phpcbf)
  • searching in Drupal API Documentation
  • translation autocomplete (php, twig, js)
  • validation and autocomplete for YAML files
  • PHPStan analysis (PHPStan, phpstan-drupal) (disabled by default)

Install

Code checking and formatting require the following packages:

composer require --dev squizlabs/php_codesniffer drupal/coder

PHPStan analysis requires the following packages:

composer require --dev phpstan/phpstan phpstan/extension-installer phpstan/phpstan-deprecation-rules mglaman/phpstan-drupal

Package paths can be specified in the extension settings.

For YAML files, the YAML extension must be installed.

Settings

Extension settings can be configured in VS Code settings (settings.json). The following drupal.* settings are available:

PHP CodeSniffer (phpcs)

  • drupal.phpcs.enabled (boolean, default: true) – Enables phpcs checker.
  • drupal.phpcs.executablePath (string) – Path to phpcs. Will use vendor/bin/phpcs if empty.
  • drupal.phpcs.args (array, default: ["--standard=Drupal,DrupalPractice"]) – Argument list of phpcs.

You can also place a phpcs.xml file in the project root, and phpcs will automatically read it (no need to specify --standard in args).

PHP Code Beautifier and Fixer (phpcbf)

  • drupal.phpcbf.enabled (boolean, default: true) – Enables phpcbf code formatter.
  • drupal.phpcbf.executablePath (string) – Path to phpcbf. Will use vendor/bin/phpcbf if empty.
  • drupal.phpcbf.args (array, default: ["--standard=Drupal,DrupalPractice"]) – Argument list of phpcbf.

PHPStan

  • drupal.phpstan.enabled (boolean, default: false) – Enables phpstan analyse.
  • drupal.phpstan.executablePath (string) – Path to phpstan. Will use vendor/bin/phpstan if empty.
  • drupal.phpstan.args (array, default: []) – Argument list of phpstan. You can also place a phpstan.neon or phpstan.neon.dist file in the project root for configuration.

Example:

"drupal.phpstan.args": [
  "--level=4"
],

Demo

Hook completion

hook

Code checking and formatting

phpcs

Translation autocomplete

The extension parses *.po files inside a module directory and autocompletes strings

PHP

t markup

Twig

twig

JavaScript

js

Drupal Search API

search

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft