-
Couldn't load subscription status.
- Fork 6
How to install and setup PHPStan
Tom de Wit edited this page Dec 11, 2020
·
2 revisions
https://phpstan.org or https://github.com/phpstan/phpstan
composer require phpstan/phpstan --dev./vendor/bin/phpstan analyse app --level max --error-format=gitlab > phpstan.jsonWe run PHPStan in the app (Laravel example) folder of the project. We output the GitLab formatted output to a JSON-file called phpstan.json.
PHPStan:
stage: Code quality
allow_failure: true
script:
- ./vendor/bin/phpstan analyse app --level max --error-format=gitlab > phpstan.json
artifacts:
paths:
- phpstan.json
when: alwaysEarlier in the configuration file you've defined the "Code quality" stage. Since quality assurance tools can fail we allow this job to fail to signal there are PHPStan errors. We then run the aforementioned script and save the output. Since GitLab, by default, doesn't store it's artifacts on failure, we overrule it's setting by always uploading phpstan.json.