Why drupal-check?

While many analysis tools exist for PHP, such as PHPStan, drupal-check stands out for being focused squarely on Drupal’s systems. What other tools would miss, drupal-check is more likely to pick up on any errors in your code. With more developers migrating their code from Drupal 7 and 8 onto 9, and maybe eventually Drupal 10, when that comes out, it’s becoming increasingly important that developers check their code as thoroughly as they can, and this tool could help. You can find drupal-check here.

How do I use it?

Well, first you have to install it. Wait, who is that? Oh, it’s our friend Composer, here to help us again. Using your command prompt, locate and change directories to that of your Drupal project, and use this command:

composer require mglaman/drupal-check --with-all-dependencies

It’s important to install it with its dependencies, since it does need quite a few. Once that’s done, you’re free to use the package, and using it is very simple. Insert the following command to use it:

php vendor\mglaman\drupal-check\drupal-check modules\webform

Allow me to explain the above command. When composer installs drupal-check, it is automatically placed in your vendor folder for easy use. So vendor\mglaman\drupal-check\drupal-check is locating where the command is to use it. The next part, modules\webform is the directory that drupal-check will be checking. Once that’s done, drupal-check will do the job of checking and analyzing the code for you.

Note: Try not to make the mistake of making drupal-check on a directory with heavy files underneath, for example, the entire modules folder, as it can cause errors

After drupal-check has finished checking, it will list down errors helpfully on the command prompt, for example:


If the check goes through without finding anything, a message telling you it’s okay will be displayed:


What I have described is only the basic use for drupal-check. While it is probably it's most prominent feature, it does have other helpful features you can make good use of. It's not perfect, and it doesn't work perfectly, but it does the job most of the time, and can be incredibly helpful.