- How do I install Laravel Pint in my Laravel project?
- Run `composer require laravel/pint --dev` to install Pint as a dev dependency. No additional configuration is needed for basic usage. Pint integrates seamlessly with Laravel’s Artisan CLI, so you can start formatting code immediately with `php artisan pint`.
- Does Laravel Pint work with Laravel 10 and PHP 8.2+?
- Yes, Laravel Pint supports Laravel 10 and PHP 8.1–8.5 (as of v1.26.0). It’s actively maintained by the Laravel team, so compatibility with newer Laravel versions is guaranteed. Check the [official docs](https://laravel.com/docs/pint) for version-specific details.
- Can I customize Pint’s rules beyond the default Laravel preset?
- Absolutely. Pint allows you to extend its default presets (Laravel, PSR12, Symfony) by creating a custom `.pint.json` config file. You can override rules, add custom paths, or even merge multiple presets. Refer to the [PHP-CS-Fixer docs](https://cs.symfony.com/) for advanced rule options.
- How do I integrate Pint into my CI/CD pipeline?
- Use Pint’s `--with-exit-status` flag to enforce code style checks in CI. For example, add `php artisan pint --diff` to your pipeline to fail builds if unstyled code is detected. For GitHub Actions, you can use the `pint` command directly in a workflow step. Pint’s exit codes make it easy to enforce consistency.
- Will Pint break my existing `.php-cs-fixer.dist.php` config?
- Pint’s default presets are designed to be opinionated but backward-compatible. If you have an existing `.php-cs-fixer.dist.php`, Pint won’t overwrite it by default. However, you may need to merge rules manually or use Pint’s `--config` flag to override settings. Always test Pint in a staging environment first.
- Can I use Pint for non-Laravel PHP projects?
- Yes, Pint is a standalone tool built on PHP-CS-Fixer. Install it globally via `composer global require laravel/pint` and run `pint` in any PHP project. While it includes Laravel-specific presets, you can switch to PSR12 or Symfony presets for non-Laravel projects. Pint’s CLI works universally.
- How do I format only specific files or directories with Pint?
- Use the `--path` flag to target specific files or directories, e.g., `php artisan pint --path=app/Http`. You can also exclude files with `--ignore-path=.pintignore`. Pint supports glob patterns, so you can fine-tune which files get formatted without affecting the entire project.
- Does Pint support parallel processing for large codebases?
- Yes, Pint includes a `--parallel` flag to speed up formatting for large projects. This is especially useful in monorepos or applications with thousands of files. However, enable it cautiously in CI/CD to avoid resource exhaustion. Test locally first with `php artisan pint --parallel --diff` to preview changes.
- How do I handle false positives in CI when using Pint?
- Use the `--diff` flag to preview changes before enforcing them. For CI, combine it with `--with-exit-status` to fail builds only on actual style violations. If you encounter flaky builds, adjust your threshold (e.g., allow minor violations) or use `.pintignore` to exclude problematic files temporarily.
- What are the alternatives to Laravel Pint, and when should I consider them?
- Alternatives include PHP-CS-Fixer (more customizable but verbose) and PHP_CodeSniffer (for linting, not auto-fixing). Use Pint if you want a minimalist, Laravel-optimized solution with zero config. Choose PHP-CS-Fixer if you need granular control over rules. Pint is ideal for teams prioritizing speed and consistency over customization.