PHPStan Composer Script


PHPStan is a powerful static analysis tool for PHP code. It uses static code analysis to catch potential errors and bugs without actually running the code. In this lesson, I will show you how to add PHPStan as a composer script and explain the benefits of doing this.

The full command for running PHPStan is:

vendor/bin/phpstan analyse -l 9 src config

Quite a lot to remember..especially when you have a few different commands. But by adding it as a script in our composer.json file, we can just do:

composer run-phpstan

Branch: https://github.com/GaryClarke/php-api-pro/tree/3-phpstan-composer-script

For a complete tutorial on PHPStan, check out the Testing PHP course > https://www.garyclarke.tech/p/testing-php

Complete and Continue  
Discussion

4 comments