$ composer require --dev "squizlabs/php_codesniffer"Now you can run vendor/bin/phpcs to check the code.
Many errors can be fixed with the next command: vendor/bin/phpcbf
The above command configures the PHPStorm inspector automatically, but you can do it manually:
- Configure path in
File->Settings->Languages->Frameworks->PHP->Quality Tools - Enable it in
File->Settings->Editor->Inspections
$ composer require --dev "phpmd/phpmd"Now you can run vendor/bin/phpmd src/ ansi ruleset.xml to check the code.
The above command configures the PHPStorm inspector automatically, but you can do it manually:
- Configure path in
File->Settings->Languages->Frameworks->PHP->Quality Tools - Enable it in
File->Settings->Editor->Inspections
$ composer require --dev "phpstan/phpstan"
$ composer require --dev "phpstan/phpstan-doctrine"
$ composer require --dev "phpstan/phpstan-webmozart-assert"Now you can run vendor/bin/phpstan analyse -c phpstan.neon -l max src/ to check the code.
The above command configures the PHPStorm inspector automatically, but you can do it manually:
- Configure path in
File->Settings->Languages->Frameworks->PHP->Quality Tools - Enable it in
File->Settings->Editor->Inspections
Include the configuration files in the root directory of your project:
PHPCodeSniffer: phpcs.xml
PHPMessDetector: ruleset.xml
PHPStan: phpstan.neon
Include the pre-commit file into .git/hooks in your project.