Skip to content

Linting

Introduction

We use Laravel Pint for enforcing consistency with regards to styling of our PHP code. It is an opinionated set of rules that we use to ensure that our PHP code is consistent and maintainable.

See full Laravel Pint documentation here.

Implementation

Pint is installed as a Composer dependency in composer.json. Presently we are using the out of the box configuration, although fine-tuning is available as described in the docs.

Pint is run with the ./vendor/bin/pint command. This can be done manually at any point, however we use Husky as the tool to enforce Pint's run on commit. Husky is a Node dependency present in package.json.

With Husky installed and initialised there is a .husky/pre-commit file that runs any number of NPM scripts on commit.

At present we have a simple npm test script present in package.json that runs Pint (./vendor/bin/pint).

This ensures that Pint is run on every commit, enforcing PHP code style consistency with each change to the codebase.