Skip to main content

What is Laravel Pint

Laravel Pint is a code style fixer built on top of PHP CS Fixer. It’s designed to work with zero configuration and automatically formats code to follow Laravel’s coding style. By automating the “coding style review comments” that so often come up in team development, you can focus code review on what really matters.

Installation

Newly created Laravel applications include Pint out of the box. For older projects, install it with Composer.

How to run it

Basic usage

Automatically fixes all .php files in the project.
You can also target specific files or directories.

Available options

Configuration

You can customize behavior by creating a pint.json file at the root of your project.
You can also explicitly specify the path to the configuration file.

Presets

A preset is a set of rules. The default is the laravel preset, which applies rules optimized for Laravel projects.

Customizing rules

You can enable or disable individual rules in pint.json. For the available rules, see the PHP CS Fixer Configurator.

Excluding files and folders

You can exclude specific folders from being checked.
To exclude by file name pattern, use notName.
To exclude by specific file path, use notPath.
Here’s an example of a pint.json configuration that works well in real-world development.
The reasons for adding each rule:
strict_comparison and declare_strict_types enforce type-strict code, so the initial fix volume can be large when adding them to an existing project. Introducing them from the start is recommended for new projects.
no_unused_imports is a setting for package development. Pint’s default is true (removes unused use statements), so this setting itself is unnecessary in ordinary Laravel projects. In package development, patterns that turn features on/off by importing traits or interfaces are common, so it’s convenient to keep false as the default and switch to true for individual packages as appropriate.

Setting up scripts in composer.json

By registering scripts for Pint in composer.json, you can run it with just composer pint.
Once registered, you can run it as follows:
In CI environments, use composer pint:test to detect style violations without modifying files. The --test option returns a non-zero exit code if errors are found, so it can be used for CI pass/fail checks.

Automatic execution with GitHub Actions

You can use GitHub Actions to automatically fix and commit code style on every push.
1

Set workflow permissions

In your GitHub repository, go to Settings > Actions > General > Workflow permissions and enable “Read and write permissions.”
2

Create the workflow file

Create .github/workflows/lint.yml.
This workflow runs Pint on every push and automatically commits any files that were fixed for style violations.
Since fixes happen before pull request review, the number of style-related review comments decreases. When rolling out to a team, run Pint on all files locally first, then add the workflow to avoid extra commits.
Last modified on July 13, 2026