phootwork/php-cs-fixer-config
Reusable PHP-CS-Fixer configuration by phootwork. Provides a shared ruleset and presets to standardize code style across projects, making it easy to apply consistent formatting in CI and local development with minimal setup.
composer require --dev phootwork/php-cs-fixer-config
.php-cs-fixer.dist.php config file in your project root that extends the provided config:
<?php
use Phootwork\CSFixer\Config;
return Config::create()
->setRiskyAllowed(true)
->setFinder(Config::createFinder(__DIR__));
vendor/bin/php-cs-fixer fix --dry-run
💡 Start with
Config::create()— it loads the shared, opinionated ruleset from the package. You don’t need to copy rules manually.
return Config::create()
->setRules([
'@PSR12' => true,
'single_import_per_statement' => false, // override base rule
'ordered_imports' => ['sort_algorithm' => 'length'],
]);
- vendor/bin/php-cs-fixer check --config=.php-cs-fixer.dist.php
.php-cs-fixer.dist.php as the source of truth for auto-formatting.Config::createFinder() only scans src/ and tests/ by default. Extend it if you have other directories:
->setFinder(Config::createFinder(__DIR__)->in(['src', 'tests', 'bin']));
setRiskyAllowed(true) if you want rules like @PHP80Migration or yoda_style. Ignoring this may cause "no fixes applied" surprises.setRules() override earlier ones. Always test overrides in dry-run mode first.^2.0) to avoid unexpected formatting shifts on minor updates. Review changelogs before upgrading.->setCacheFile(__DIR__.'/.php-cs-fixer.cache)`) for faster repeated runs in local/dev environments.no_alias_functions, strict_comparison).How can I help you explore Laravel packages today?