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

woohoolabs/coding-standard

Woohoo Labs PHP Coding Standard for PHP_CodeSniffer, based on PSR-12 and inspired by Doctrine and Slevomat rules. Install via Composer and drop in the provided phpcs.xml to start enforcing consistent code style (PHP 7.4+).

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Purpose Alignment: Remains a PHP coding standard (static analysis tool) for Laravel/PHP projects, not a runtime dependency. The shift to slevomat/coding-standard v8 suggests deeper integration with modern PHP tooling (e.g., PHP 8.1+ features, stricter PSR compliance).
  • Laravel Compatibility:
    • Improved: slevomat/coding-standard v8 aligns with PSR-12 and PHP 8.1+ (e.g., named arguments, match expressions). May introduce Blade template rules or Laravel-specific conventions (e.g., Illuminate\ namespace handling).
    • Risk: If the package enforces stricter rules (e.g., disallowing var_dump in production), conflicts with Laravel’s defaults may arise.
  • Tooling Integration:
    • PHP-CS-Fixer: Likely updated to v3.x (slevomat’s recommended tool).
    • PHPStan/Psalm: Better compatibility with PHP 8.1+ types.
    • IDE Support: May require updated inspection profiles (e.g., PHPStorm 2023.2+).

Integration Feasibility

  • Low Risk: Still non-intrusive, but dependency updates (slevomat v8) may require:
    • PHP 8.1+: Verify Laravel version (Laravel 10+ supports PHP 8.2; 9.x may need upgrades).
    • PHP-CS-Fixer v3: Check for breaking changes (e.g., new rule sets like @SlevomatPlus).
  • Customization:
    • New Rules: slevomat v8 may introduce Laravel-specific rules (e.g., Illuminate\ namespace enforcement, Blade syntax).
    • Deprecations: Older rules (e.g., PSR-1/PSR-2) may be removed; audit .php-cs-fixer.dist.php.

Technical Risk

Risk Area Severity Mitigation Strategy
PHP 8.1+ Requirement High Upgrade Laravel/PHP if <8.1 (or use --ignore-errors).
Rule Breaking Changes Medium Run php-cs-fixer fix --dry-run pre-migration.
slevomat v8 Compatibility Medium Test with composer require slevomat/coding-standard:^8.0.
Blade Template Rules Low Whitelist resources/views/ if rules are too strict.
IDE Misconfiguration Low Update PHPStorm/VSCode inspection profiles.

Key Questions

  1. What new Laravel-specific rules does slevomat v8 introduce? (E.g., Illuminate\ namespace, Blade syntax.)
  2. Are there breaking changes from slevomat v7? (Check migration guide.)
  3. Does this version support PHP 8.2 features? (e.g., new attributes, first-class callable syntax.)
  4. How are Blade templates handled? (Will it enforce rules in .blade.php files?)
  5. Are there performance improvements? (e.g., faster static analysis.)
  6. What’s the deprecation policy for old rules? (E.g., PSR-1/PSR-2.)

Integration Approach

Stack Fit

  • Primary Use Case: Development workflows (CI/CD, IDE, pre-commit hooks).
  • Compatible Stack:
    • Laravel 10+ (PHP 8.1+; Laravel 9.x may require PHP upgrade).
    • PHP-CS-Fixer v3 (recommended for slevomat v8).
    • PHP 8.1+ (required for full feature support).
  • Non-Compatible:
    • PHP <8.1 or Laravel <9.
    • Projects without modern tooling (e.g., no PHP-CS-Fixer).

Migration Path

  1. Pre-Migration Audit:
    • Run composer require --dev slevomat/coding-standard:^8.0 in a test environment.
    • Execute php-cs-fixer fix --dry-run --rules=@WoohooLabs to identify violations.
  2. Pilot Phase:
    • Apply to a single module (e.g., a feature branch).
    • Test CI/CD integration with --strict mode.
  3. Full Rollout:
    • Update composer.json:
      "require-dev": {
          "woohoolabs/coding-standard": "^2.4",
          "php-cs-fixer": "^3.0",
          "slevomat/coding-standard": "^8.0"
      }
      
    • Configure PHP-CS-Fixer to use @WoohooLabs rule set (may need updates).
    • Train team on new rules (e.g., Blade syntax, Laravel namespace).

Compatibility

  • With Laravel:
    • Blade Templates: Verify if slevomat v8 includes Blade-specific rules (e.g., @foreach indentation, @php blocks).
    • Artisan/Commands: Check if CLI output formatting rules conflict with Laravel’s conventions.
  • With Other Tools:
    • PHPStan: Ensure no conflicts with type-checking rules (e.g., disallowed var_dump).
    • EditorConfig: May need updates for new line-length or indentation rules.
  • Backward Compatibility:
    • Low: slevomat v8 is a major update; expect breaking changes.
    • Mitigation: Use --ignore-errors temporarily for critical violations.

Sequencing

  1. Pre-Integration:
    • Upgrade PHP to 8.1+ and Laravel to 10 if needed.
    • Backup .php-cs-fixer.dist.php and phpcs.xml.
  2. Tooling Setup:
    • Update php-cs-fixer config:
      return PhpCsFixer\Config::create()
          ->setRules([
              '@WoohooLabs' => true,
              '@PHP81Migration' => true, // Enable PHP 8.1+ rules
          ]);
      
    • Add to CI/CD (GitHub Actions example):
      - name: Run PHP-CS-Fixer (slevomat v8)
        run: vendor/bin/php-cs-fixer fix --rules=@WoohooLabs --allow-risky=yes
      
  3. Developer Onboarding:
    • Update IDE inspection profiles (e.g., PHPStorm’s PHP_CodeSniffer validation).
    • Add a pre-commit hook (Husky + php-cs-fixer).

Operational Impact

Maintenance

  • Pros:
    • Stricter Standards: Aligns with PHP 8.1+ and modern Laravel practices.
    • Reduced Debt: Catches issues earlier (e.g., deprecated syntax).
  • Cons:
    • Higher Initial Cost: PHP/Laravel upgrades may be needed.
    • Rule Maintenance: slevomat v8 may require frequent updates (e.g., new PHP features).
  • Ownership:
    • Assign a dedicated maintainer to manage rule sets and tooling.
    • Document exception processes (e.g., @codingStandardsIgnoreStart).

Support

  • Developer Experience:
    • Positive: Better alignment with PHP 8.1+ (e.g., named args, match expressions).
    • Negative: Steep learning curve if rules are unfamiliar (e.g., Blade syntax).
  • Support Channels:
    • Create a #coding-standards-v8 channel for slevomat-specific issues.
    • Document common exceptions (e.g., "Laravel migrations can use var_dump in dev").
  • Onboarding:
    • Workshop: Demo php-cs-fixer with slevomat v8 rules.
    • Cheat Sheet: List of new rules (e.g., "Use readonly properties in PHP 8.1+").

Scaling

  • Performance:
    • Improved: slevomat v8 may optimize rule processing (verify benchmarks).
    • CI/CD: Use parallelization for large codebases (e.g., split by directory).
  • Team Growth:
    • Scalable: Rules are self-documenting and enforce modern PHP.
    • Customization: Allow teams to extend rules (e.g., project-specific conventions).
  • Multi-Repo:
    • Use composer scripts or GitHub templates to standardize setup across repos.

Failure Modes

Failure Scenario Impact Mitigation
PHP 8.1+ Upgrade Blockers Dev environment fails Use Docker/Laravel Sail for consistency.
Rule Overhead Slows CI Builds time
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity