Skip to content

How to install and setup Phan

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

Phan

https://github.com/phan/phan

Installation

composer require phan/phan --dev

After installation, Phan needs to be initialised. Refer to their documentation for full examples.

./vendor/bin/phan --init

A .phan/config.php file will be generated.

CLI usage

./vendor/bin/phan --output-mode=json --output=phan.json

We run Phan from the project root and set the output mode to JSON. We output the result to a JSON-file called phan.json.

GitLab CI/CD configuration

Phan:
  stage: Code quality
  allow_failure: true
  script:
    - ./vendor/bin/phan --output-mode=json --output=phan.json
  artifacts:
    paths:
      - phan.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 Phan 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 phan.json.