PHPackages                             mglaman/drupal-check - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. mglaman/drupal-check

ActiveProject[CLI &amp; Console](/categories/cli)

mglaman/drupal-check
====================

CLI tool for running checks on a Drupal code base

1.5.0(1y ago)3436.8M↓37.8%71[22 issues](https://github.com/mglaman/drupal-check/issues)[10 PRs](https://github.com/mglaman/drupal-check/pulls)20GPL-2.0-or-laterPHPPHP ^7.2.5|^8.0CI passing

Since Feb 14Pushed 4w ago9 watchersCompare

[ Source](https://github.com/mglaman/drupal-check)[ Packagist](https://packagist.org/packages/mglaman/drupal-check)[ GitHub Sponsors](https://github.com/mglaman)[ Fund](https://opencollective.com/phpstan-drupal)[ RSS](/packages/mglaman-drupal-check/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (12)Versions (59)Used By (20)

drupal-check [![Build](https://github.com/mglaman/drupal-check/actions/workflows/php.yml/badge.svg)](https://github.com/mglaman/drupal-check/actions/workflows/php.yml) [![CircleCI](https://camo.githubusercontent.com/8aaf9ac682b949143f82fd4d649379102590791fc4a152d9652c4d1494cd1c6e/68747470733a2f2f636972636c6563692e636f6d2f67682f6d676c616d616e2f64727570616c2d636865636b2e7376673f7374796c653d737667)](https://circleci.com/gh/mglaman/drupal-check) [![Latest release](https://camo.githubusercontent.com/849710ae7cbfff9b0725205f2a2215a5b79204e430524c3d71565d27951f7719/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d676c616d616e2f64727570616c2d636865636b2e737667)](https://github.com/mglaman/drupal-check/releases/latest)
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#drupal-check---)

Built on [PHPStan](https://github.com/phpstan/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](https://github.com/mglaman/drupal-check/wiki/Drupal-9-Readiness) instructions for details on how this tool can help.

Sponsors
--------

[](#sponsors)

[![undpaul](https://camo.githubusercontent.com/e426166a09f6112358743da87b7a6242ff1cde5720f29ef609d58e72dd149957/68747470733a2f2f7777772e756e647061756c2e64652f7468656d65732f637573746f6d2f756e647061756c332f6c6f676f2e737667)](https://www.undpaul.de/) [![undpaul](https://camo.githubusercontent.com/d95d83f40f7c2549480147991a3dff295e46dbacfa4e8460f17e008ed86a7f40/68747470733a2f2f7777772e6f70746173792e636f6d2f696d616765732f6c6f676f2e737667)](https://www.optasy.com/)

[Would you like to sponsor?](https://github.com/sponsors/mglaman)

Requirements
------------

[](#requirements)

- PHP &gt;=7.2

Installation
------------

[](#installation)

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

```
composer require mglaman/drupal-check --dev

```

Usage
-----

[](#usage)

```
php vendor/bin/drupal-check [options] [--] ...

```

Arguments:

- `path` - The Drupal code path(s) to inspect

Options:

- `--drupal-root[=DRUPAL-ROOT]` - Path to Drupal root.
- `--format[=FORMAT]` - Formatter to use: raw, table, checkstyle, json, or junit \[default: "table"\]
- `-d, --deprecations` - Check for deprecations
- `-a, --analysis` - Check code analysis
- `-s, --style` - Check code style
- `--php8` - Set PHPStan phpVersion for 8.1 (Drupal 10 requirement)
- `--memory-limit[=MEMORY-LIMIT]` - Memory limit for analysis
- `-e, --exclude-dir[=EXCLUDE-DIR]` - Directories to exclude. Separate multiple directories with a comma, no spaces.
- `--no-progress` - Do not show progress bar, only results
- `-h, --help` - Display this help message
- `-q, --quiet` - Do not output any message
- `-V, --version` - Display this application version
- `--ansi` - Force ANSI output
- `--no-ansi` - Disable ANSI output
- `-n, --no-interaction` - Do not ask any interactive question
- `-v|vv|vvv, --verbose` - Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples:

- 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
-----------------------------------------------------------

[](#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 \
  phpstan/phpstan-deprecation-rules
```

Create a `phpstan.neon` file with the following:

```
parameters:
	customRulesetUsed: true
	ignoreErrors:
		- '#\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
	excludePaths:
		- */tests/Drupal/Tests/Listeners/Legacy/*
		- */tests/fixtures/*.php
		- */settings*.php
		- */bower_components/*
		- */node_modules/*
```

You can copy this from the Upgrade Status module directly [https://git.drupalcode.org/project/upgrade\_status/-/blob/8.x-3.x/deprecation\_testing\_template.neon](https://git.drupalcode.org/project/upgrade_status/-/blob/8.x-3.x/deprecation_testing_template.neon)

Drupal Check - VS Code Extension
--------------------------------

[](#drupal-check---vs-code-extension)

You can run Drupal Check from VSCode using this extension:

The code can be found at:

License
-------

[](#license)

[GPL v2](LICENSE.txt)

Issues
------

[](#issues)

Submit issues and feature requests here: .

### Known Issues

[](#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](https://github.com/mglaman/drupal-check/issues/9)
- If you run into issues with other libraries, please submit an issue to this project.

Contributing
------------

[](#contributing)

See the [CONTRIBUTING.md](CONTRIBUTING.md).

References
----------

[](#references)

- [Writing better Drupal code with static analysis using PHPStan](https://glamanate.com/blog/writing-better-drupal-code-static-analysis-using-phpstan)
- [PHPStan: Find Bugs In Your Code Without Writing Tests!](https://medium.com/@ondrejmirtes/phpstan-2939cd0ad0e3)
- [Online PHPStan Analyzer](https://phpstan.org/)

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance66

Regular maintenance activity

Popularity65

Solid adoption and visibility

Community42

Growing community involvement

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 82.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~231 days

Total

33

Last Release

664d ago

PHP version history (3 changes)1.0.5PHP ~7.1

1.1.0PHP ~7.2

1.1.8PHP ^7.2.5|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/98c03d4d2a6aa9b5ecdfc565e8f90f53f0a8f6c2757048a148b34b166d78266c?d=identicon)[mglaman](/maintainers/mglaman)

---

Top Contributors

[![mglaman](https://avatars.githubusercontent.com/u/3698644?v=4)](https://github.com/mglaman "mglaman (231 commits)")[![violinist-bot](https://avatars.githubusercontent.com/u/27495990?v=4)](https://github.com/violinist-bot "violinist-bot (11 commits)")[![josephdpurcell](https://avatars.githubusercontent.com/u/778111?v=4)](https://github.com/josephdpurcell "josephdpurcell (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![joeparsons](https://avatars.githubusercontent.com/u/471936?v=4)](https://github.com/joeparsons "joeparsons (3 commits)")[![arlina-espinoza](https://avatars.githubusercontent.com/u/4062676?v=4)](https://github.com/arlina-espinoza "arlina-espinoza (2 commits)")[![byrond](https://avatars.githubusercontent.com/u/767994?v=4)](https://github.com/byrond "byrond (2 commits)")[![MPParsley](https://avatars.githubusercontent.com/u/1823998?v=4)](https://github.com/MPParsley "MPParsley (2 commits)")[![Sergey-Orlov](https://avatars.githubusercontent.com/u/4222740?v=4)](https://github.com/Sergey-Orlov "Sergey-Orlov (2 commits)")[![GueGuerreiro](https://avatars.githubusercontent.com/u/15708144?v=4)](https://github.com/GueGuerreiro "GueGuerreiro (1 commits)")[![kasperg](https://avatars.githubusercontent.com/u/73966?v=4)](https://github.com/kasperg "kasperg (1 commits)")[![mallezie](https://avatars.githubusercontent.com/u/1926222?v=4)](https://github.com/mallezie "mallezie (1 commits)")[![markdorison](https://avatars.githubusercontent.com/u/20355?v=4)](https://github.com/markdorison "markdorison (1 commits)")[![dan612](https://avatars.githubusercontent.com/u/16948781?v=4)](https://github.com/dan612 "dan612 (1 commits)")[![vijaycs85](https://avatars.githubusercontent.com/u/1220029?v=4)](https://github.com/vijaycs85 "vijaycs85 (1 commits)")[![mxr576](https://avatars.githubusercontent.com/u/1755573?v=4)](https://github.com/mxr576 "mxr576 (1 commits)")[![opdavies](https://avatars.githubusercontent.com/u/339813?v=4)](https://github.com/opdavies "opdavies (1 commits)")[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (1 commits)")[![tormi](https://avatars.githubusercontent.com/u/146800?v=4)](https://github.com/tormi "tormi (1 commits)")[![tyler36](https://avatars.githubusercontent.com/u/7234392?v=4)](https://github.com/tyler36 "tyler36 (1 commits)")

---

Tags

drupaldrupal-8hacktoberfestphpstan

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mglaman-drupal-check/health.svg)

```
[![Health](https://phpackages.com/badges/mglaman-drupal-check/health.svg)](https://phpackages.com/packages/mglaman-drupal-check)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k193.1M3.0k](/packages/composer-composer)[illuminate/console

The Illuminate Console package.

13045.3M6.1k](/packages/illuminate-console)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136400.8k14](/packages/rector-rector-src)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54642.4k4](/packages/jolicode-castor)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

761.1k](/packages/whatsdiff-whatsdiff)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
