phlak/coding-standards
Predefined PHP-CS-Fixer coding standards by PHLAK. Install as a dev dependency, initialize via composer exec cs init or create a config using ConfigFactory with a Finder, then run php-cs-fixer. Supports adding or overriding rules via ConfigFactory::make().
Install the package as a dev dependency and initialize the config with the built-in CLI tool — no manual file editing needed.
composer require --dev phlak/coding-standards
composer exec cs init
.php-cs-fixer.dist.php with sensible defaults for Laravel projects../vendor/bin/php-cs-fixer fix src tests
composer.json scripts for routine use (e.g., "cs:fix": "php-cs-fixer fix").ConfigFactory::make() for dynamic config — use it in .php-cs-fixer.dist.php instead of static arrays.
return PHLAK\CodingStandards\ConfigFactory::make($finder)
->setIndent("\t") // Laravel uses tabs; tweak if needed
->setRiskyAllowed(); // Enable for modern PHP upgrades (e.g., PHP 8.3+ features)
ConfigFactory::make($finder, [
'phpdoc_summary' => false, // Disable_summary formatting (e.g., for Doctrine annotations)
'global_namespace_import' => ['import_classes' => true],
]);
# .github/workflows/ci.yaml
- name: Fix coding standards
run: composer cs:fix
- name: Check standards (CI guard)
run: ./vendor/bin/php-cs-fixer fix --dry-run
.php-cs-fixer.dist.php created by cs init is replaced by ConfigFactory::make() logic — don’t mix static config definitions.'ordered_imports' => [...] replaces the default config, not merges it. Use ConfigFactory::make()->getRules() to fetch defaults first if partial customization is needed../vendor/bin/php-cs-fixer fix --clear-cacheno_unused_imports override if using ConfigFactory, as this package already enforces import ordering — conflicts otherwise cause noisy diffs.How can I help you explore Laravel packages today?