Skip to main content

What is Laravel Pint?

Laravel Pint is an opinionated PHP code style fixer built on top of PHP CS Fixer. It fixes code style issues automatically, following Laravel’s opinionated coding style by default. Pint removes the need for style-related review comments, so your team can focus on what matters in code review.

Installation

Pint is automatically installed with all new Laravel applications. For older projects, install it via Composer:
composer require laravel/pint --dev

Running Pint

Basic usage

Fix code style issues in all .php files in your project:
./vendor/bin/pint
Target a specific file or directory:
./vendor/bin/pint app/Models
./vendor/bin/pint app/Models/User.php

Options

OptionDescription
--testInspect without making changes. Returns a non-zero exit code if errors are found
--dirtyOnly inspect files with uncommitted changes according to Git
--diff=[branch]Only inspect files that differ from the given branch
--repairFix errors but also exit with a non-zero code if any fixes were applied
--parallelRun in parallel mode (experimental) for better performance
--max-processes=4Limit the number of parallel processes (used with --parallel)
-vShow a detailed list of all changes made
--configPath to a custom pint.json configuration file
--presetPreset to use for this run
# Check only, no changes
./vendor/bin/pint --test

# Only uncommitted files
./vendor/bin/pint --dirty

# Run in parallel
./vendor/bin/pint --parallel

Configuring Pint

Create a pint.json file in the project root to customize behavior:
{
    "preset": "laravel"
}
Pass a config path explicitly when running Pint:
./vendor/bin/pint --config vendor/my-company/coding-style/pint.json

Presets

A preset is a predefined collection of rules. The default is the laravel preset.
PresetDescription
laravelLaravel’s opinionated coding style (default)
psr12PSR-12 coding standard
perPER Coding Style
symfonySymfony coding style
emptyNo rules — define everything from scratch
./vendor/bin/pint --preset psr12

Rules

Override or add individual rules in pint.json. Browse available rules at the PHP CS Fixer Configurator.
{
    "preset": "laravel",
    "rules": {
        "simplified_null_return": true,
        "array_indentation": false,
        "new_with_parentheses": {
            "anonymous_class": true,
            "named_class": true
        }
    }
}

Excluding files and folders

Exclude entire directories:
{
    "exclude": [
        "my-specific/folder"
    ]
}
Exclude files matching a name pattern:
{
    "notName": [
        "*-my-file.php"
    ]
}
Exclude a specific file by path:
{
    "notPath": [
        "path/to/excluded-file.php"
    ]
}
A practical pint.json used in real projects:
{
    "preset": "laravel",
    "rules": {
        "no_unused_imports": false,
        "strict_comparison": true,
        "declare_strict_types": true
    }
}
Why each rule is worth adding:
RuleEffect
no_unused_importsSet to false to keep unused use statements. Pint’s default is true (remove them), so this entry is not needed in a normal Laravel application
strict_comparisonReplaces == with === and != with !==, preventing unexpected type-coercion bugs
declare_strict_typesAdds declare(strict_types=1); to the top of every file, enforcing type safety
strict_comparison and declare_strict_types can produce a large initial diff when added to an existing project. Start with these rules on new projects to avoid the one-time cleanup cost.
no_unused_imports is primarily useful for package development. Pint’s default is true (removes unused use statements), so a normal Laravel application does not need this entry at all. In packages, traits and interfaces are sometimes imported specifically to toggle a feature on or off, so setting this to false preserves those intentional imports. A practical approach: add "no_unused_imports": false as a baseline and switch individual packages to true when you are sure all imports are used.

Adding scripts to composer.json

Register Pint as a Composer script so you can run it with composer pint:
{
    "scripts": {
        "pint": "./vendor/bin/pint",
        "pint:test": "./vendor/bin/pint --test"
    }
}
Run the scripts:
# Fix code style
composer pint

# Check only, no changes
composer pint:test
Use composer pint:test in CI pipelines to detect style violations without modifying files. The --test option returns a non-zero exit code on failure, so your CI check will fail if any violations are found.

CI/CD with GitHub Actions

Automatically fix and commit code style on every push using GitHub Actions.
1

Enable 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:
name: Fix Code Style

on: [push]

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        php: [8.4]

    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          tools: pint

      - name: Run Pint
        run: pint

      - name: Commit linted files
        uses: stefanzweifel/git-auto-commit-action@v6
This workflow runs Pint on every push and automatically commits any fixed files back to the branch.
To avoid a large initial commit, run Pint locally across your entire codebase before adding the workflow. This separates the style cleanup from ongoing feature work.
Last modified on April 4, 2026