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

lcobucci/coding-standard

PHP_CodeSniffer ruleset based on Doctrine’s coding standard with small tweaks. Install and use it in your projects to enforce consistent formatting and code style via phpcs in CI and local development.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel/PHP Alignment: The package is a PHP_CodeSniffer (PHPCS) ruleset derived from Doctrine’s standard, making it natively compatible with Laravel’s PHP-based architecture. It enforces PSR-12 with minor customizations (e.g., stricter array syntax, attribute formatting), which aligns with Laravel’s evolving best practices (e.g., Laravel 11’s PHP 8.4+ requirements).
  • Tooling Ecosystem: Integrates seamlessly with:
    • PHPCS 4.0+ (required by v12.0.0+).
    • PHP-CS-Fixer (for automated fixes).
    • CI/CD pipelines (GitHub Actions, GitLab CI) via phpcs commands.
    • Pre-commit hooks (e.g., Husky, Laravel Pint).
  • Modern PHP Support: PHP 8.4+ requirement ensures compatibility with:
    • Laravel 11+ (PHP 8.2+ but optimized for 8.4+).
    • Symfony 7+.
    • New PHP features (e.g., array{} syntax, attributes, union types).

Integration Feasibility

  • Low Friction: No database or external service dependencies. Installation is a single composer require with minimal configuration (e.g., adding to phpcs.xml or CI scripts).
  • Backward Compatibility: Minor version bumps (e.g., v11.2.0 adds PHP 8.5 support) are non-breaking. Major versions (e.g., v12.0.0) require PHP 8.4+ but include upgrade guides (e.g., Doctrine’s migration docs).
  • Customization: Extendable via PHPCS’s rule overrides or by forking (though the package’s minimal modifications reduce fork risk).

Technical Risk

Risk Area Assessment Mitigation Strategy
PHP Version Lock-in Requires PHP 8.4+ (v12.0.0+). Phase adoption: Start with v11.x (PHP 8.2+) for legacy projects, migrate to v12.x.
PHPCS Version PHPCS 4.0+ required (v12.0.0+). Audit CI/CD for PHPCS upgrades; use php-cs-fixer as a fallback for older setups.
Rule Overrides Custom rules may conflict with existing PHPCS configs. Test in a staging environment; use phpcs --ignore for exceptions.
Performance PHPCS can slow CI pipelines if not cached. Cache PHPCS results (e.g., GitHub Actions actions/cache).
False Positives Strict rules (e.g., array syntax) may flag legacy code. Configure .php-cs-fixer.dist.php to exclude specific files/directories.

Key Questions for the TPM

  1. PHP Version Strategy:

    • Is the team ready to adopt PHP 8.4+? If not, can v11.x (PHP 8.2+) suffice for now?
    • Are there legacy codebases that would require rule exceptions or a gradual migration?
  2. CI/CD Impact:

    • How will PHPCS results be gated in PRs (e.g., GitHub branch protection rules)?
    • Should php-cs-fixer be used for auto-fixes in pre-commit hooks?
  3. Customization Needs:

    • Are there team-specific rules (e.g., naming conventions, docblock templates) that conflict with this standard?
    • Should the package be forked for internal tweaks, or managed via PHPCS overrides?
  4. Tooling Stack:

    • Is PHPCS 4.0+ already in use, or will this require upgrading squizlabs/php_codesniffer?
    • Will this replace or complement existing tools (e.g., Psalm, Pest)?
  5. Adoption Phasing:

    • Should this be rolled out project-by-project or team-wide?
    • How will developer ramp-up be handled (e.g., training, documentation)?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Native Support: Works with Laravel’s PHP foundation without framework-specific modifications.
    • Artisan Integration: Can be wrapped in a custom Artisan command (e.g., php artisan lint) for developer convenience.
    • Pint Compatibility: Aligns with Laravel Pint (PHP-CS-Fixer wrapper) for automated fixes.
  • Symfony/Modern PHP:
    • Supports Symfony’s dependency injection and attribute rules (e.g., [ParamConverter] formatting).
    • Compatible with Symfony Flex and Reusable Components.
  • Tooling Synergy:
    • PHP-CS-Fixer: Use alongside for auto-correction (e.g., php-cs-fixer fix).
    • Git Hooks: Integrate with pre-commit to block violations early.
    • IDE Plugins: PHPCS rules can be enabled in PHPStorm/VSCode for real-time feedback.

Migration Path

Phase Action Tools/Commands
Assessment Audit current PHPCS/PHP-CS-Fixer configs for conflicts. composer why-not lcobucci/coding-standard, phpcs --standard=current --sniffs
Pilot Project Test in a non-critical Laravel module or Symfony bundle. composer require lcobucci/coding-standard, update phpcs.xml.
CI/CD Integration Add PHPCS to CI pipeline (e.g., GitHub Actions). Example: phpcs --standard=lcobucci --error-severity=3 src/
Developer Onboarding Document rules and provide a fix-it script (PHP-CS-Fixer). php-cs-fixer fix --rules=@lcobucci
Full Rollout Enforce in all repositories; archive legacy PHPCS configs. Update composer.json across monorepo or team projects.

Compatibility

  • Laravel-Specific:
    • Blade Templates: PHPCS may flag Blade syntax (e.g., @foreach). Exclude resources/views in phpcs.xml.
    • Service Providers: Attribute rules (e.g., [Inject]) are supported in PHP 8.0+.
  • Symfony-Specific:
    • YAML/XML Configs: No impact; PHPCS targets PHP files only.
    • Event Listeners: Attribute formatting (e.g., [ListenerEvent]) is enforced.
  • Legacy Code:
    • Use --ignore for deprecated files or gradual enforcement (e.g., phpcs --ignore=legacy/).

Sequencing

  1. Standardize Configuration:
    • Create a team-wide phpcs.xml template with LCobucci’s rules.
    • Example:
      <config defaultStandard="lcobucci">
          <arg name="encoding" value="utf-8"/>
          <file>./src</file>
          <exclude>./tests</exclude>
      </config>
      
  2. CI/CD Pipeline:
    • Add PHPCS to build checks (e.g., GitHub Actions):
      - name: Run PHPCS
        run: composer require --dev lcobucci/coding-standard && vendor/bin/phpcs --standard=lcobucci --error-severity=3 src/
      
  3. Developer Workflow:
    • Integrate with pre-commit hooks (e.g., Husky):
      {
        "hooks": {
          "pre-commit": "phpcs --standard=lcobucci --warning-severity=0"
        }
      }
      
  4. Automated Fixes:
    • Use PHP-CS-Fixer for non-breaking changes (e.g., docblock alignment):
      composer require --dev php-cs-fixer
      ./vendor/bin/php-cs-fixer fix --rules=@lcobucci
      

Operational Impact

Maintenance

  • Low Overhead:
    • No active maintenance required from the team; the package is updated by the maintainer (last release: 2026-04-13).
    • Dependency Management: PHPCS and Doctrine CS updates are handled via Composer.
  • Rule Updates:
    • Minor version bumps (e.g., v11.x → v12.x) may require PHP version upgrades but include clear changelogs.
    • Fork Risk: Minimal (only 1 PR in 5 years; Doctrine’s ruleset is stable).

Support

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.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle