laravel/pint
Laravel Pint is an opinionated PHP code style fixer for minimalists. Built on PHP-CS-Fixer, it makes it easy to keep your Laravel and PHP projects clean and consistent with a simple, standardized formatting workflow.
--diff mode).composer require laravel/pint --dev + php artisan pint). No breaking changes to existing workflows if used as a replacement for PHP-CS-Fixer.--diff, --test, and --exit-status enable granular CI integration (e.g., fail builds on style violations).php-cs-fixer (v3.x), which may introduce breaking changes if major versions are skipped. Monitor upstream updates (e.g., v3.87.0 compatibility fixes in v1.25.0).--parallel) improves speed but may strain CI resources if misconfigured (e.g., excessive processes). Test with --max-processes=N in CI.Pint/phpdoc_type_annotations_only) may conflict with team-specific PSRs. Validate against existing .php-cs-fixer.dist.php configs.--diff for incremental adoption.php artisan pint). Ideal for monorepos or projects using Laravel’s tooling../vendor/bin/pint) but loses Laravel-specific presets/rules. Requires manual config alignment.if: pint --test).--diff for real-time feedback (e.g., PHPStorm’s "Reformat Code" with Pint)..php-cs-fixer.dist.php (if any) for conflicts with Pint’s preset../vendor/bin/pint --diff to identify discrepancies.devDependencies and test in a feature branch.--test mode to validate CI compatibility..github/workflows/)..php-cs-fixer.dist.php in favor of Pint’s config (if using defaults).array_syntax, concat_space). Custom rules require explicit configuration.extends: laravel in .pint.php or CLI flags (e.g., --preset=laravel).--parallel in CI to avoid resource spikes.composer require laravel/pint --dev
.pint.php:
return [
'preset' => 'laravel',
'rules' => [
'@PER-CS' => true, // Add custom rules
],
];
- name: Run Pint
run: php artisan pint --test
composer.json scripts:
"scripts": {
"pint": "pint",
"pint:fix": "pint --fix"
}
php-cs-fixer and Pint releases for breaking changes. Example: Pint v1.25.0 fixed compatibility with PHP-CS-Fixer v3.87.0.Pint/phpdoc_type_annotations_only) may require updates if PHP-CS-Fixer evolves. Test with --dry-run before major updates..pint.php to avoid forked configs across repos. Use extends for shared rules.--verbose to debug rule application.--no-cache or configure cache_file in .pint.php.--parallel on CI environments (Windows/Linux differences noted in v1.24.0).--parallel for large codebases (test --max-processes=4 in CI).--diff to limit scope (e.g., ./app --diff).php artisan pint --parallel --verbose.--test mode to avoid local tooling conflicts.| Failure Scenario | Mitigation | Detection |
|---|---|---|
| Pint fails in CI due to style violations | Use --test in CI to fail builds. Locally, use --fix to auto-correct. |
CI exit code (non-zero on failure). |
| Parallel mode crashes on Windows | Fallback to sequential mode or adjust --max-processes. |
Test on Windows CI runners. |
| Custom rules break existing code | Validate with --diff before merging. Use --bail to stop on first error. |
Local pre-commit hooks. |
| Configuration conflicts | Centralize .pint.php and use extends: laravel to inherit defaults. |
pint --dry-run to preview changes. |
| PHP version incompatibility | Pin Pint version in composer.json (e.g., ^1.26). |
Test matrix in CI (PHP 8.1–8.5). |
--fix, --diff, --test).- name: Lint PHP
run: |
php artisan pint --test || exit 0 # Allow failures for now
How can I help you explore Laravel packages today?