Skip to content

How to install and setup PHPLint

Tom de Wit edited this page Dec 11, 2020 · 3 revisions

PHPLint

https://github.com/overtrue/phplint

Installation

composer require overtrue/phplint --dev

CLI usage

./vendor/bin/phplint ./ --exclude=vendor --no-cache --json=phplint.json

We run PHPLint in the root folder of the project but we exclude the vendor folder. We output the result to a JSON-file called phplint.json.

GitLab CI/CD configuration

PHPLint:
  stage: Code quality
  allow_failure: true
  script:
    - ./vendor/bin/phplint ./ --exclude=vendor --no-cache --json=phplint.json
  artifacts:
    paths:
      - phplint.json
    when: always

Earlier 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 PHPLint 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 phplint.json.