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

Coding Standard Laravel Package

symplify/coding-standard

Ready-to-use PHP CS Fixer and PHP_CodeSniffer rules bundled as a coding standard, with Symplify tooling integration. Helps keep projects consistent, modern, and clean with configurable rule sets suited for CI and team workflows.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package via Composer:
    composer require --dev symplify/coding-standard
    
  2. Create a config file (e.g., phpcs.xml or ecs.php) and extend the provided config:
    <config name="Symplify\CodingStandard\CodeQuality\Symfony\PhpCsFixerConfig">
        <rule set="symplify" />
    </config>
    
    Or, for ECS (recommended for newer setups):
    use Symplify\CodingStandard\Symfony\EasyCodingStandardConfig;
    
    return EasyCodingStandardConfig::configure()->withPaths(['src', 'tests']);
    
  3. Run the checker locally:
    vendor/bin/ecs check src tests
    # or
    vendor/bin/php-cs-fixer fix --diff
    
  4. Automate in CI: Add ecs check or php-cs-fixer fix --dry-run to your pipeline.

Implementation Patterns

  • Unified formatting across Laravel apps: Apply consistently in app, tests, and config directories. Especially useful for large monorepos or multi-package organizations.
  • CI enforcement: Use GitHub Actions or GitLab CI with ecs check --no-progress to fail builds on style issues.
  • Pre-commit hooks: Integrate with lint-staged or Husky to auto-fix PHP files on stage/commit:
    {
      "lint-staged": {
        "*.php": ["vendor/bin/ecs fix --no-progress", "git add"]
      }
    }
    
  • Laravel-specific tweaks: Override rules for framework conventions (e.g., disable blank_line_after_opening_tag for cleaner controller files). Use symplify/coding-standard as the base and layer project-specific rules.
  • Gradual adoption: Start with --fix in CI using --dry-run first, then gradually relax or lock down rules per service or team.

Gotchas and Tips

  • ECS vs PHPCS: Prefer ecs (EasyCodingStandard) over php-cs-fixer CLI directly—ecs provides better Laravel integration, more actionable output, and simpler config.
  • Version drift: Ensure PHP version compatibility—some rules require PHP 8.0+ features. Check symplify/coding-standard’s composer.json for minimum PHP requirements.
  • False positives: Disable strict rules selectively via config if they conflict with Laravel idioms (e.g., disable no_superfluous_elseif if you rely on explicit conditions for readability).
  • Config caching: Use ecs check --debug to inspect which rules applied—and why—helpful when debugging misfires.
  • Custom rules: Extend with your own rulesets by extending Symplify\EasyCodingStandard\Contract\ConfigInterface or using withConfiguredRules() in your ECS config.
  • IDE integration: Install PHPStan or PHP-CS-Fixer plugins in VS Code/PHPStorm to mirror ecs behavior in-editor—config sharing helps here.
  • Big repos: For legacy codebases, start with --fix-dry-run + --severity flags to surface low-impact violations first, then ramp up enforcement incrementally.
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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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