symplify/easy-coding-standard
Easy Coding Standard (ECS) makes PHP coding standards effortless on PHP 7.2–8.5. Fast parallel runs, supports PHP_CodeSniffer and PHP-CS-Fixer, uses prepared rule sets, generates ecs.php config on first run, and can check and auto-fix code with --fix.
Start by installing ECS via Composer: composer require --dev symplify/easy-coding-standard. Run vendor/bin/ecs check src to see current violations. Generate a baseline config with vendor/bin/ecs init—this creates ecs.php (or ecs.yaml) and pre-fills recommended sets like @PHP81 or @Symfony. The first use case is typically a one-time codebase cleanup: run vendor/bin/ecs check src --fix to auto-correct style issues across the project. Check the generated diff before committing—it’s safe for most formatting rules.
ecs.php (PHP config) for complex setups—define sets, directories, and custom rules. For example:
use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
->withSets([__DIR__ . '/vendor/symplify/easy-coding-standard/config/set/php81.yaml'])
->withRules([SomeCustomRule::class]);
vendor/bin/ecs check --no-progress to GitHub Actions, GitLab CI, or Bitbucket Pipelines. Use --error-format=github to render inline comments in PRs.pre-commit (using husky + lint-staged or custom pre-commit hook) to auto-fix only staged files: vendor/bin/ecs check --fix --diff.ecs.php includes or environment-based configs (ecs.local.php excluded from VCS).@Symfony set), then progressively enable stricter ones like @PhpCsFixer or custom DeadCode sets.var/cache/ecs. If config changes, clear manually: rm -rf var/cache/ecs or use --clear-cache.@Symfony + @PHP-CS-Fixer) may cause fights—use withSkip() to disable conflicting fixers:
$parameters->set(Option::SKIP, [
SomeFixer::class, // avoid double-formatting
]);
--report output for manual remediation.--debug to spot bottlenecks, or restrict paths with --paths. Consider --parallel in CI for speed.ecs.php config as a separate package (e.g., my-team/coding-standard) and require it as a Composer dependency.vendor/bin/ecs check --diff --dry-run before --fix to review changes—especially after config updates.How can I help you explore Laravel packages today?