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 discovers and installs PHP_CodeSniffer coding standards (rulesets) from Composer packages. It configures PHPCS installed_paths for you, avoiding manual symlinks and configuration. Supports PHPCS 3/4 and Composer 2.2+.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Seamless Composer Integration: The package leverages Composer’s plugin system, aligning perfectly with Laravel’s dependency management workflow. It eliminates manual installed_paths configuration in phpcs.xml by automating PHPCS standard discovery and registration.
  • Decoupled from Core Logic: Operates independently of Laravel’s framework-specific components (e.g., no Blade, Eloquent, or routing dependencies), making it a low-risk add-on for code quality pipelines.
  • Standardized Workflow: Enforces consistency across teams by dynamically linking PHPCS standards to Composer-managed packages, reducing configuration drift.

Integration Feasibility

  • Minimal Laravel-Specific Overhead: No Laravel-specific hooks or middleware required. Integration is purely via composer.json and CLI execution (./vendor/bin/phpcs).
  • CI/CD Friendly: Designed for automated environments (e.g., GitHub Actions, GitLab CI), with explicit support for script-based invocation (composer run-script).
  • Backward Compatibility: Supports PHP 5.4+ (though Laravel’s minimum is PHP 8.0+), Composer 2.2+, and PHPCS 3.x/4.x, ensuring no forced upgrades.

Technical Risk

  • Plugin Execution Permissions: Composer 2.2+ requires explicit allow-plugins configuration, which may introduce onboarding friction if teams lack Composer admin rights.
  • Search Depth Limitations: Default 3-level directory depth for standard discovery could fail in deeply nested Laravel modules (e.g., custom packages in packages/). Mitigated via extra.phpcodesniffer-search-depth.
  • Global vs. Local Plugin Conflict: Global Composer installations might override project-specific versions, risking inconsistent behavior. Documented but rarely encountered in CI/CD.
  • PHPCS Version Mismatches: If a project mixes PHPCS 3.x/4.x standards, the plugin may silently fail to register some rulesets. Requires explicit version alignment in require-dev.

Key Questions

  1. CI/CD Pipeline Impact:

    • How will this plugin interact with existing post-install-cmd or post-update-cmd scripts in Laravel’s composer.json?
    • Will parallel Composer operations (e.g., composer install --no-scripts) break PHPCS standard registration?
  2. Performance:

    • What is the overhead of scanning vendor/ for standards during composer install? (Critical for large Laravel monorepos.)
  3. Custom Standards:

    • How will the team handle project-specific PHPCS standards (e.g., custom rules in app/Rules/)? Will they need manual installed_paths entries?
  4. Dependency Conflicts:

    • Could conflicting PHPCS standard versions (e.g., phpcompatibility/php-compatibility:^9.0 vs. ^10.0) cause runtime errors?
  5. Debugging:

    • What tools exist to audit which standards are registered and why? (e.g., phpcs -i vs. composer why-not dealerdirect/phpcodesniffer-composer-installer)

Integration Approach

Stack Fit

  • Laravel Ecosystem: Ideal for Laravel projects using:
    • PHPCS for Static Analysis: Replaces manual installed_paths in phpcs.xml with Composer-managed standards.
    • Custom Coding Standards: Simplifies distribution of internal standards (e.g., company/phpcodesniffer-standards) via Packagist.
    • CI/CD Pipelines: Automates standard registration in GitHub Actions/GitLab CI without custom scripts.
  • Toolchain Synergy:
    • Works alongside Laravel Pint (PHP-CS-Fixer) for auto-fixing.
    • Complements PHPStan or Psalm for type-based analysis.
    • Integrates with Laravel Forge or Deployer for server-side PHPCS checks.

Migration Path

  1. Assessment Phase:
    • Audit existing phpcs.xml for manual installed_paths entries.
    • Identify all PHPCS standard packages (e.g., psr12, squizlabs/php_codesniffer) in composer.json.
  2. Pilot Integration:
    • Add dealerdirect/phpcodesniffer-composer-installer to require-dev.
    • Configure allow-plugins and test with composer install.
    • Verify phpcs -i lists expected standards.
  3. Full Rollout:
    • Replace installed_paths in phpcs.xml with <config name="installed_paths" value="composer-autoloaded"/>.
    • Update CI/CD to run composer install --no-interaction (with allow-plugins pre-configured).
  4. Custom Standards:
    • Package internal standards as phpcodesniffer-standard type packages (e.g., acme/phpcodesniffer-custom-rules).
    • Publish to a private Packagist repo or GitHub Packages.

Compatibility

Component Compatibility Mitigation
Laravel Version All (no framework dependencies) None
Composer Version 2.2+ (Laravel 8+ default) Downgrade not recommended; upgrade if needed.
PHPCS Version 3.x/4.x (Laravel’s squizlabs/php_codesniffer typically uses 4.x) Align versions in require-dev.
PHP Version 5.4+ (Laravel 8+ uses 8.0+) No impact; Laravel’s PHP version takes precedence.
Custom PHPCS Rules May require manual installed_paths if outside vendor/ Use extra.phpcodesniffer-search-depth or symlink.

Sequencing

  1. Pre-requisite: Ensure squizlabs/php_codesniffer is in require-dev (Laravel typically includes this).
  2. Plugin Installation: Add dealerdirect/phpcodesniffer-composer-installer to require-dev.
  3. Permission Setup: Run composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true or add to composer.json.
  4. Standard Registration: Add PHPCS standard packages (e.g., psr12, wp-coding-standards/wpcs).
  5. Configuration Update: Replace installed_paths in phpcs.xml with <config name="installed_paths" value="composer-autoloaded"/>.
  6. Testing: Validate with composer install && ./vendor/bin/phpcs -i.
  7. CI/CD Update: Add composer install --no-interaction to workflows (ensure allow-plugins is configured).

Operational Impact

Maintenance

  • Low Ongoing Effort:
    • No manual updates to phpcs.xml when adding/removing standards (handled by Composer).
    • Standard updates propagate via composer update.
  • Dependency Management:
    • Version conflicts between PHPCS standards may require composer why-not debugging.
    • Plugin updates are infrequent (MIT license, active maintenance).

Support

  • Troubleshooting:
    • Common issues:
      • Permission Denied: Composer 2.2+ plugin execution blocked. Fix: composer config allow-plugins....
      • Missing Standards: Check composer.json for phpcodesniffer-standard packages or adjust search-depth.
      • CI Failures: Ensure allow-plugins is set in CI environment variables.
    • Debugging Tools:
      • composer why dealerdirect/phpcodesniffer-composer-installer (checks dependencies).
      • ./vendor/bin/phpcs --config-show (validates installed_paths).
  • Documentation:
    • Minimal; relies on Composer Plugin Docs and PHPCS docs.
    • Recommendation: Create an internal runbook for:
      • Standard registration workflows.
      • Handling custom rules outside vendor/.

Scaling

  • Performance:
    • Composer Install Time: Minimal overhead (~1–2s for standard discovery in medium-sized projects).
    • CI/CD: Parallelizable with other post-install-cmd scripts.
  • Large Teams:
    • Reduces "works on my machine" issues by standardizing PHPCS environments.
    • Enables self-service standard adoption (teams add standards via composer require --dev).

Failure Modes

Failure Scenario Impact Mitigation
Composer Plugin Blocked PHPCS standards not registered; phpcs fails with "no standards found". Pre-configure allow-plugins in CI/CD.
PHPCS Version Mismatch Some standards fail to load (e.g., PHPCS
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai