CLI tool for running checks on a Drupal code base

Fund package maintenance!
Open Collective

Installs: 2 226 784

Dependents: 27

Suggesters: 0

Security: 0

Stars: 301

Watchers: 10

Forks: 59

Open Issues: 19



Built on PHPStan, this static analysis tool will check for correctness (e.g. using a class that doesn't exist), deprecation errors, and more.

Why? While there are many static analysis tools out there, none of them run with the Drupal context in mind. This allows checking contrib modules for deprecation errors thrown by core.

Are you ready for Drupal 9? Check out our Drupal 9 Readiness instructions for details on how this tool can help.


undpaul iO

Would you like to sponsor?


  • PHP >=7.2


You can install this in your project using Composer as a development dependency like so:

composer require mglaman/drupal-check --dev

You can also install this globally using Composer like so:

composer global require mglaman/drupal-check

Refer to Composer's documentation on how to ensure global binaries are in your PATH:



php vendor/bin/drupal-check [OPTIONS] [DIRS]


  • OPTIONS - See "Options" for allowed values. Specify multiples in sequence, e.g. -ad.
  • DIRS - One or more directories within the root of a Drupal project.


  • -a Check analysis
  • -d Check deprecations (default)
  • -e Exclude directories. Wildcards work. Separate multiple excluded directories with commas, no spaces. e.g.: */tests/codeception/acceptance/*.php
  • --drupal-root Path to Drupal root. Fallback option if drupal-check could not identify Drupal root from the provided path(s).


  • Check the address contrib module:
php vendor/bin/drupal-check web/modules/contrib/address
  • Check the address contrib module for deprecations:
php vendor/bin/drupal-check -d web/modules/contrib/address
  • Check the address contrib module for analysis:
php vendor/bin/drupal-check -a web/modules/contrib/address

Rollback update to PHPStan level 2 for deprecation analysis

drupal-check:1.4.0 set PHPStan's analysis level to 2 for deprecations and 6 for analysis. This ensures basic analysis errors are fixed to provide the best deprecated code detection experience. You can read more about PHPStan's rule levels here:

If you do not want to run PHPStan at level 2 and only report deprecation messages, use the following instructions

composer remove mglaman/drupal-check
composer require  --dev phpstan/phpstan \
  phpstan/extension-installer \
  mglaman/phpstan-drupal \

Create a phpstan.neon file with the following:

	customRulesetUsed: true
		- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
		- '#Plugin definitions cannot be altered.#'
		- '#Missing cache backend declaration for performance.#'
		- '#Plugin manager has cache backend specified but does not declare cache tags.#'

	# FROM mglaman/drupal-check/phpstan/base_config.neon
	reportUnmatchedIgnoredErrors: false
		- */tests/Drupal/Tests/Listeners/Legacy/*
		- */tests/fixtures/*.php
		- */settings*.php
		- */bower_components/*
		- */node_modules/*

You can copy this from the Upgrade Status module directly

Drupal Check - VS Code Extension

You can run Drupal Check from VSCode using this extension:

The code can be found at:


GPL v2


Submit issues and feature requests here:

Known Issues

There are conflicts with dependencies shared with other libraries that might be installed on a Drupal project:

  • This tool does not work with BLT 9: #9
  • If you run into issues with other libraries, please submit an issue to this project.


See the