Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Php Cs Fixer

Php Cs Fixer Laravel Package

friendsofphp/php-cs-fixer

PHP CS Fixer automatically fixes PHP code to match coding standards. Use built-in rule sets (PER-CS, Symfony, PhpCsFixer) or custom config to unify style, modernize PHP/PHPUnit code, and apply safe or risky migrations. Supports PHP 7.4–8.5.

View on GitHub
Deep Wiki
Context7

A tool to automatically fix PHP code style

Frequently asked questions about Php Cs Fixer
How do I install PHP-CS-Fixer for a Laravel project?
Run `composer require --dev friendsofphp/php-cs-fixer` in your Laravel project root. This installs it as a dev dependency. For conflicts, use `php-cs-fixer/shim` instead. Access the CLI tool via `./vendor/bin/php-cs-fixer` after installation.
Which rule set should I use for Laravel projects?
Start with `@Symfony` (Laravel’s de facto standard) or `@PhpCsFixer` for stricter rules. For legacy projects, `@PER-CS` (PSR-12) is a safe baseline. Use `./vendor/bin/php-cs-fixer init` to generate a config and customize it in `.php-cs-fixer.dist.php`.
Can PHP-CS-Fixer handle Laravel-specific files like Blade templates?
PHP-CS-Fixer primarily targets `.php` files and won’t process Blade templates by default. For Blade, consider custom rules or pre-processing with tools like `laravel-shift/blade-cs-fixer`. Exclude non-PHP files in your config with `exclude: ['*.blade.php']` if needed.
How do I integrate PHP-CS-Fixer into GitHub Actions for Laravel?
Add a step to your workflow YAML like this: `- name: Fix coding standards run: ./vendor/bin/php-cs-fixer fix --diff --allow-risky=yes`. Use `--diff` to preview changes and `--allow-risky=yes` for auto-migration rules. Cache results with `--cache-file=.php-cs-fixer.cache` for faster CI runs.
What’s the best way to avoid false positives when fixing Laravel code?
Use `--dry-run` to preview changes before applying them. Exclude sensitive files (e.g., `vendor/`, `config/`) in `.php-cs-fixer.dist.php`. For risky rules like `ReturnAssignmentFixer`, test on a backup branch first or use `@auto:risky` selectively.
Does PHP-CS-Fixer support PHP 8.5 in Laravel projects?
As of now, PHP-CS-Fixer supports up to PHP 8.5 but may require enabling unsupported versions with `--allow-unsupported-php-version=yes`. Check the [supported versions](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer#supported-php-versions) and consider contributing if you need official support.
How can I enforce PHP-CS-Fixer rules in pre-commit hooks for Laravel?
Use tools like `husky` or `pre-commit` to run PHP-CS-Fixer before commits. Add this to your `.pre-commit-config.yaml`: `- repo: local project: . hook: ./vendor/bin/php-cs-fixer fix --dry-run --diff`. Configure it to fail builds on violations or warn only.
What are the alternatives to PHP-CS-Fixer for Laravel?
For Laravel, consider `laravel-shift/laravel-pint` (a Laravel-specific wrapper for PHP-CS-Fixer) or `dealerdirect/phpcodesniffer-composer-installer` for PHP_CodeSniffer. Pint is lighter but less customizable, while PHP_CodeSniffer offers more linting without auto-fixing.
How do I handle rule conflicts between PHP-CS-Fixer and Laravel Pint?
Audit your rule sets with `./vendor/bin/php-cs-fixer list-rules` and merge configurations in `.php-cs-fixer.dist.php`. Prioritize `@Symfony` for consistency with Laravel Pint’s defaults. Use `rules: { 'rule_name': 'disabled' }` to override conflicting rules explicitly.
Can PHP-CS-Fixer modernize Laravel code to PHP 8.x features?
Yes, use the `@autoPHPMigration` or `@autoPHPMigration:risky` rule sets to auto-update syntax like named arguments, match expressions, or union types. Test thoroughly with `--dry-run` first, as risky rules may alter logic unintentionally.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai