This extension supports only Drupal projects that use the Composer template drupal/recommended-project.
- 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 from Visual Studio Marketplace or Open VSX Registry
Code checking and formatting require the following packages:
composer require --dev squizlabs/php_codesniffer drupal/coderPHPStan analysis requires the following packages:
composer require --dev phpstan/phpstan phpstan/extension-installer phpstan/phpstan-deprecation-rules mglaman/phpstan-drupalPackage paths can be specified in the extension settings.
For YAML files, the YAML extension must be installed.
Extension settings can be configured in VS Code settings (settings.json). The following drupal.* settings are available:
drupal.phpcs.enabled(boolean, default:true) – Enables phpcs checker.drupal.phpcs.executablePath(string) – Path to phpcs. Will usevendor/bin/phpcsif 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).
drupal.phpcbf.enabled(boolean, default:true) – Enables phpcbf code formatter.drupal.phpcbf.executablePath(string) – Path to phpcbf. Will usevendor/bin/phpcbfif empty.drupal.phpcbf.args(array, default:["--standard=Drupal,DrupalPractice"]) – Argument list of phpcbf.
drupal.phpstan.enabled(boolean, default:false) – Enables phpstan analyse.drupal.phpstan.executablePath(string) – Path to phpstan. Will usevendor/bin/phpstanif empty.drupal.phpstan.args(array, default:[]) – Argument list of phpstan. You can also place aphpstan.neonorphpstan.neon.distfile in the project root for configuration.
Example:
"drupal.phpstan.args": [
"--level=4"
],The extension parses *.po files inside a module directory and autocompletes strings






