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.
composer.json configuration, adhering to Laravel’s modularity.post-install-cmd), enabling integration with Laravel’s post-update-cmd or CI/CD pipelines.composer require --dev and allow-plugins configuration—no Laravel-specific setup.php artisan phpcs:run) to run PHPCS with installed standards.composer run-script install-codestandards).phpcodesniffer-standard packages (mitigated by flexible version constraints like * or ^0.4.1 || ^0.5).allow-plugins configuration (Composer 2.2+). Global installations may conflict with project-specific versions.vendor/ directory structure changes (e.g., custom paths in config/filesystems.php).composer install (configurable via extra.phpcodesniffer-search-depth).composer run-script phpcs)?php artisan phpcs:fix)?vendor/bin/phpcs) without modification.phpunit.xml for pre-commit hooks (e.g., phpcs checks before tests run).Phase 1: Proof of Concept
composer require --dev dealerdirect/phpcodesniffer-composer-installer
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
phpcodesniffer-standard package (e.g., slevomat/coding-standard):
composer require --dev slevomat/coding-standard
./vendor/bin/phpcs -i # List installed standards
./vendor/bin/phpcs app/ # Test compliance
Phase 2: CI/CD Integration
composer.json scripts:
"scripts": {
"post-install-cmd": ["@install-codestandards"],
"post-update-cmd": ["@install-codestandards"]
}
composer install --no-dev followed by PHPCS checks.Phase 3: Artisan Integration (Optional)
app/Console/Commands/PhpcsCommand.php):
public function handle()
{
$this->call('vendor:publish', ['--provider' => 'PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer\Plugin']);
$this->info('PHPCS standards installed. Run `phpcs` directly.');
}
app/Console/Kernel.php:
protected $commands = [
Commands\PhpcsCommand::class,
];
type: phpcodesniffer-standard per spec.dealerdirect/phpcodesniffer-composer-installer and phpcodesniffer-standard packages to composer.json.allow-plugins and optional extra.phpcodesniffer-search-depth.composer install or composer update to auto-configure PHPCS../vendor/bin/phpcs -i and integrate into CI/CD.composer.json can pin versions:
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
slevomat/coding-standard may require version bumps.composer run-script install-codestandards -- --verbose
allow-plugins is configured and Composer 2.2+ is used.vendor/ or adjust search-depth.vendor/ between runs to avoid re-scanning.CONTRIBUTING.md or DEVELOPMENT.md in the Laravel repo detailing:
phpcodesniffer-search-depth cautiously (default: 3).phpcodesniffer-standard package to ensure consistency.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Composer plugin blocked | PHPCS standards not installed | Pre-configure allow-plugins in CI/CD. |
| Standard package missing | Broken PHPCS commands | Validate composer.json dependencies. |
| Path resolution errors | Standards not detected | Use absolute paths or adjust search-depth. |
| PHPCS version mismatch | Runtime errors | Pin PHPCS version in composer.json. |
| CI/CD cache issues | Flaky PHPCS checks | Cache vendor/ directory between runs. |
README.md (e.g., "Run composer install to auto-configure standards").How can I help you explore Laravel packages today?