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

Phpcodesniffer Composer Installer Laravel Package

dealerdirect/phpcodesniffer-composer-installer

Composer installer plugin that automatically registers PHP_CodeSniffer coding standards (rulesets) from your dependencies. It scans installed packages for phpcodesniffer-standard rulesets and configures PHPCS installed_paths—no symlinks or manual setup.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Plugin Add to your project's composer.json under require-dev:

    composer require --dev dealerdirect/phpcodesniffer-composer-installer
    

    Grant plugin execution permission (Composer 2.2+):

    composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
    
  2. Add PHPCS Standards Require any phpcodesniffer-standard packages (e.g., phpcompatibility/php-compatibility):

    composer require --dev phpcompatibility/php-compatibility
    
  3. Verify Installation Run composer install and test PHPCS:

    ./vendor/bin/phpcs -i  # Lists installed standards
    

First Use Case

  • Automate PHPCS Setup: Replace manual installed_paths configuration in .phpcs.xml by letting Composer auto-detect and register standards from installed packages.

Implementation Patterns

Workflow Integration

  1. Standardized PHPCS Setup

    • CI/CD Pipelines: Add to post-install-cmd in composer.json:
      "scripts": {
        "post-install-cmd": ["@install-codestandards"]
      }
      
    • Local Development: Run composer install to auto-configure PHPCS.
  2. Custom Standards

    • Create a package with type: phpcodesniffer-standard and include it in require-dev:
      "require-dev": {
        "your-vendor/your-standard": "*"
      }
      
  3. Search Depth Customization

    • Override default 3-level search depth in extra:
      "extra": {
        "phpcodesniffer-search-depth": 5
      }
      

Common Patterns

  • Project-Wide Standards: Use phpcodesniffer-standard packages (e.g., squizlabs/php_codesniffer, wp-coding-standards/wpcs).
  • Relative Paths: Standards in the project root are auto-detected (no symlinks needed).
  • Script Hooks: Trigger plugin manually via composer run-script install-codestandards.

Gotchas and Tips

Pitfalls

  1. Composer 2.2+ Plugin Permission

    • Issue: Composer prompts for plugin execution permission on first run.
    • Fix: Preemptively add allow-plugins to composer.json or run:
      composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
      
  2. Global vs. Local Plugin Conflict

    • Issue: Global Composer install may override local plugin version.
    • Fix: Use --prefer-dist or ensure local composer.json has the correct version.
  3. Version Conflicts

    • Issue: Multiple standards requiring different plugin versions (e.g., ^0.7 vs. ^1.0).
    • Fix: Use flexible version constraints (e.g., * or ^0.7 || ^1.0).

Debugging Tips

  • Verify Installed Standards: Run ./vendor/bin/phpcs -i to list detected standards.
  • Check Search Paths: Debug with composer --verbose install to see plugin execution logs.
  • Manual Trigger: Test plugin independently via:
    composer run-script install-codestandards
    

Extension Points

  1. Custom Standards Paths

    • Override installed_paths in .phpcs.xml if auto-detection fails:
      <arg name="installed_paths" value="vendor/your-standard"/>
      
  2. Post-Install Scripts

    • Chain with other scripts (e.g., phpunit):
      "scripts": {
        "test": ["@install-codestandards", "phpunit"]
      }
      
  3. CI/CD Optimization

    • Cache vendor/ to avoid re-running the plugin on every build.

Quirks

  • PHP_CodeSniffer 4.x: Requires plugin ^0.7.0+; older versions may need downgrading.
  • Windows Paths: Use forward slashes (/) in installed_paths for cross-platform compatibility.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata