chiiya/code-style-php
Reusable code style configs for PHP 8.1+ projects, combining PHP-CS-Fixer, EasyCodingStandard (ECS), and Rector. Install via Composer and import the provided rule sets into your tool config files to standardize formatting and refactors.
.php-cs-fixer.dist.php.composer.json and monitor upstream updates.OrderedClassElementsFixer) were removed due to false positives. Laravel-specific rules (e.g., for Facades, Blade templates) may need manual tuning.composer install or CI, slowing down pipelines.main branch)..php-cs-fixer.dist.php).str_replace to Str::replace) in CI or via a script.dev dependencies:
composer require chiiya/code-style-php --dev
.php-cs-fixer.dist.php with the package’s config (or merge rules).ecs.php) and Rector config (rector.php) to composer.json:
"extra": {
"ecs": ["vendor/bin/ecs check src"]
}
- name: Run ECS
run: vendor/bin/ecs check --config=ecs.php src
- name: Run Rector
run: vendor/bin/rector process src --dry-run
--dry-run).ecs.php or rector.php:
// ecs.php
return ECSConfig::fromPhpStormConfig()
->withRules([
new NoUnusedPhpDocTagsRule(),
// Override default rules
]);
composer.json to avoid surprises:
"config": {
"allow-plugins": {
"friendsofphp/php-cs-fixer": true
}
}
CONTRIBUTING.md or CODE_STYLE.md in the repo to explain:
# Fix PHP-CS-Fixer issues
composer run fix-cs
# Run ECS
composer run lint
# Apply Rector refactoring (dry-run)
composer run rector
--dry-run).vendor/ and node_modules/:
return ECSConfig::fromPhpStormConfig()
->withPaths(['src', 'tests']);
--parallel and limit to specific paths.| Failure Mode | Impact | Mitigation |
|---|---|---|
| Strict rules block PRs | Slows down development. | Start with `-- |
How can I help you explore Laravel packages today?