mll-lab/php-cs-fixer-config
Shared php-cs-fixer configuration package. Install as a dev dependency and use the config($finder) helper in .php-cs-fixer.php. Optionally enable risky rules via risky($finder), override specific rules, or further customize the returned Config instance.
Install via Composer:
composer require --dev mll-lab/php-cs-fixer-config
Then create a .php-cs-fixer.php file in your project root that extends the provided config:
<?php
return MllLab\PHPCSFixerConfig\Config::create();
Run the fixer locally to apply standards:
./vendor/bin/php-cs-fixer fix
This gives you immediate, consistent formatting with zero configuration—ideal for bootstrapping a new Laravel project or cleaning up legacy code. The new LineBreakBeforeThrowExpressionFixer ensures consistent line breaks before throw expressions, improving readability in exception handling.
./vendor/bin/php-cs-fixer fix --dry-run --diff in your GitHub Actions/GitLab CI pipeline to fail builds on style violations.pre-commit (e.g., via husky + lint-staged) to auto-fix staged PHP files:
"lint-staged": {
"*.php": "php-cs-fixer fix"
}
phpdoc_return_self_type for Eloquent methods). The new LineBreakBeforeThrowExpressionFixer can be leveraged to standardize exception handling in Laravel's exception handlers or middleware.composer.json to prevent breaking changes from upstream rule updates.handle() methods in Laravel middleware.blank_line_after_opening_tag, no_unused_imports). If your codebase uses older patterns (e.g., short_open_tag), expect many auto-fixes on first run. The new LineBreakBeforeThrowExpressionFixer may introduce changes in exception-heavy files.typed_collection) require PHP 8.0+. Check Config::MIN_PHP_VERSION..php-cs-fixer.php, e.g.:
return MllLab\PHPCSFixerConfig\Config::create()
->setRiskyAllowed(true)
->setRules([
'phpdoc_var_annotation_correct_order' => false,
'line_break_before_throw_expression' => true, // Explicitly enable the new rule
]);
--using-cache=no --verbose to trace rule behavior. Cache files can stale on config changes."editor.formatOnSave": true with the PHP Intelephense extension and php-cs-fixer binary path for IDE-level auto-formatting.risky rules by default (e.g., no_superfluous_elseif, no_unset_cast). Always review first-run diffs carefully.LineBreakBeforeThrowExpressionFixer will enforce a line break before throw expressions. If your codebase lacks this, expect changes in exception-heavy files (e.g., App\Exceptions\Handler.php). Test with --dry-run first.How can I help you explore Laravel packages today?