# Laravel Pint Laravel Pint is an opinionated PHP code style fixer for minimalists built on top of PHP-CS-Fixer. It provides a zero-configuration approach to ensuring your PHP code follows consistent style conventions, with the Laravel coding style as the default preset. Pint automatically detects and fixes code style violations across your entire project, supporting multiple industry-standard presets including PSR-12, PER, and Symfony. The tool integrates seamlessly into development workflows through CLI commands, CI/CD pipelines, and editor integrations. It supports parallel processing for faster execution on large codebases, stdin input for real-time editor formatting, and multiple output formats (JSON, XML, checkstyle, JUnit, GitLab) for integration with various tooling. Configuration is handled through a simple `pint.json` file that allows customizing presets, rules, and file exclusions without complex setup. ## Installation Install Laravel Pint as a development dependency using Composer. ```bash # Install Pint in your project composer require laravel/pint --dev # Or install globally composer global require laravel/pint ``` ## Basic Usage Run Pint to fix code style issues in your project. ```bash # Fix all PHP files in current directory (uses Laravel preset by default) ./vendor/bin/pint # Fix specific file or directory ./vendor/bin/pint app/Models/User.php ./vendor/bin/pint app/Http/Controllers # Fix multiple paths ./vendor/bin/pint app/Models app/Http/Controllers ``` ## Test Mode (Dry Run) Check for code style issues without modifying files. ```bash # Check for issues without fixing (exit code 1 if issues found) ./vendor/bin/pint --test # Stop on first error found ./vendor/bin/pint --bail # Fix files but return exit code 1 if changes were made (useful for CI) ./vendor/bin/pint --repair ``` ## Preset Selection Choose from built-in presets for different coding standards. ```bash # Use Laravel preset (default) ./vendor/bin/pint --preset laravel # Use PSR-12 preset ./vendor/bin/pint --preset psr12 # Use PER (PHP Evolving Recommendation) preset ./vendor/bin/pint --preset per # Use Symfony preset ./vendor/bin/pint --preset symfony # Use empty preset (no rules, only custom rules from pint.json) ./vendor/bin/pint --preset empty ``` ## Configuration File (pint.json) Create a `pint.json` file in your project root to customize Pint's behavior. ```json { "preset": "laravel", "exclude": [ "tests/Fixtures", "legacy" ], "notName": [ "*-generated.php" ], "notPath": [ "path/to/excluded-file.php" ], "rules": { "array_syntax": { "syntax": "short" }, "binary_operator_spaces": { "default": "single_space" }, "blank_line_before_statement": { "statements": ["return", "throw"] }, "concat_space": { "spacing": "one" }, "declare_strict_types": true, "final_class": true, "ordered_imports": { "sort_algorithm": "alpha" }, "single_quote": true } } ``` ## Configuration Inheritance Extend a base configuration file to share settings across projects. ```json { "extend": "./base.json", "preset": "laravel", "rules": { "declare_strict_types": true, "final_class": true } } ``` Base configuration file (`base.json`): ```json { "preset": "psr12", "rules": { "array_push": true, "date_time_immutable": true, "fully_qualified_strict_types": true, "global_namespace_import": { "import_classes": true, "import_constants": true } } } ``` ## Git Integration (Diff Mode) Only fix files that have changed since branching from a specific branch. ```bash # Fix files changed since branching from main ./vendor/bin/pint --diff main # Fix files changed since branching from master ./vendor/bin/pint --diff master # Fix files changed since branching from remote branch ./vendor/bin/pint --diff origin/main ``` ## Dirty Mode Only fix files with uncommitted changes in Git. ```bash # Fix only files with uncommitted changes ./vendor/bin/pint --dirty ``` ## Stdin Input (Editor Integration) Format code from stdin for real-time editor integration. ```bash # Format code from stdin (use - as path placeholder) echo '