Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Easy Coding Standard Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Project-level configuration: Use 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]);
    
  • CI integration: Add vendor/bin/ecs check --no-progress to GitHub Actions, GitLab CI, or Bitbucket Pipelines. Use --error-format=github to render inline comments in PRs.
  • Git hooks: Hook ECS via pre-commit (using husky + lint-staged or custom pre-commit hook) to auto-fix only staged files: vendor/bin/ecs check --fix --diff.
  • Module-specific tuning: Override config per subdirectory using ecs.php includes or environment-based configs (ecs.local.php excluded from VCS).
  • Gradual onboarding: Start with loose rules (@Symfony set), then progressively enable stricter ones like @PhpCsFixer or custom DeadCode sets.

Gotchas and Tips

  • Cache invalidation: ECS caches results in var/cache/ecs. If config changes, clear manually: rm -rf var/cache/ecs or use --clear-cache.
  • Rule conflicts: Overlapping rules (e.g., @Symfony + @PHP-CS-Fixer) may cause fights—use withSkip() to disable conflicting fixers:
    $parameters->set(Option::SKIP, [
        SomeFixer::class, // avoid double-formatting
    ]);
    
  • No auto-fix for all: Not all sniffs are auto-fixable (e.g., PHPCS errors about docblocks). Check --report output for manual remediation.
  • Performance tuning: For large repos, use --debug to spot bottlenecks, or restrict paths with --paths. Consider --parallel in CI for speed.
  • Custom rule sets: Create reusable rule groups by exporting your ecs.php config as a separate package (e.g., my-team/coding-standard) and require it as a Composer dependency.
  • Diff preview: Always run vendor/bin/ecs check --diff --dry-run before --fix to review changes—especially after config updates.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation