symplify/coding-standard
Opinionated PHP coding standard with 23 fixers for clean, consistent, readable code—no config required. Designed to run with Symplify Easy Coding Standard (ECS); install via Composer and auto-fix formatting like arrays, strict types spacing, line length, and method chaining.
Pros:
symplify preset) while offering granular control.--fix flag), reducing manual refactoring effort.Cons:
LineLengthFixer) require manual tuning, which may conflict with team preferences.Laravel Compatibility:
Toolchain Fit:
vendor/bin/ecs.pre-commit scripts (e.g., Husky).Dependencies:
Low-Medium:
LineLengthFixer) may clash with existing team conventions.Mitigation:
--fix) or flagged for review?symplify:risky).Primary Use Case:
Laravel-Specific Benefits:
Toolchain Synergy:
@phpstan-/@psalm- annotations, improving static analysis integration.Assessment Phase:
vendor/bin/ecs --dry-run on a sample branch to identify conflicts.Pilot Integration:
composer.json dev dependencies:
composer require symplify/easy-coding-standard --dev
ecs.php:
return ECSConfig::configure()
->withPreparedSets(symplify: true)
->withPaths([__DIR__ . '/src']);
Gradual Rollout:
--fix in pre-commit hooks (auto-correct).Deprecation Handling:
symplify/coding-standard with ECS’s native sets:
->withPreparedSets(ecs: true) // Uses ECS's built-in rules
Laravel Versions:
IDE/Editor:
PHP Intelephense + ECS CLI.Conflict Resolution:
ecs.php:
->withRule(Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer::class)
->lineLength(120) // Customize line length
- name: Run ECS
run: vendor/bin/ecs check src
composer require --dev symplify/easy-coding-standard
vendor/bin/ecs --fix
contributing.md as a requirement.--fix in a one-time migration script.Pros:
Cons:
LineLengthFixer breaking long SQL queries).vendor/bin/ecs --why-failed to debug violations.--parallel).vendor/bin/ecs src/Modules).->withPaths([__DIR__ . '/src'])
->exclude([__DIR__ . '/tests'])
| Failure Mode | Impact | Mitigation |
|---|---|---|
| CI Build Failures | Blocks merges | Run locally first (--dry-run). |
| Auto-fix Overcorrection | Introduces bugs (e.g., line breaks) | Review changes in PRs. |
| Rule Conflicts with Legacy Code | Manual fixes required | Exclude problematic files/dirs. |
| ECS Version Incompatibility | Broken builds | Pin versions in composer.json. |
| IDE Plugin Issues | False warnings | Use CLI for critical checks. |
check, --fix, --why-failed).How can I help you explore Laravel packages today?