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.
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
Add PHPCS Standards
Require any phpcodesniffer-standard packages (e.g., phpcompatibility/php-compatibility):
composer require --dev phpcompatibility/php-compatibility
Verify Installation
Run composer install and test PHPCS:
./vendor/bin/phpcs -i # Lists installed standards
installed_paths configuration in .phpcs.xml by letting Composer auto-detect and register standards from installed packages.Standardized PHPCS Setup
post-install-cmd in composer.json:
"scripts": {
"post-install-cmd": ["@install-codestandards"]
}
composer install to auto-configure PHPCS.Custom Standards
type: phpcodesniffer-standard and include it in require-dev:
"require-dev": {
"your-vendor/your-standard": "*"
}
Search Depth Customization
extra:
"extra": {
"phpcodesniffer-search-depth": 5
}
phpcodesniffer-standard packages (e.g., squizlabs/php_codesniffer, wp-coding-standards/wpcs).composer run-script install-codestandards.Composer 2.2+ Plugin Permission
allow-plugins to composer.json or run:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
Global vs. Local Plugin Conflict
--prefer-dist or ensure local composer.json has the correct version.Version Conflicts
^0.7 vs. ^1.0).* or ^0.7 || ^1.0)../vendor/bin/phpcs -i to list detected standards.composer --verbose install to see plugin execution logs.composer run-script install-codestandards
Custom Standards Paths
installed_paths in .phpcs.xml if auto-detection fails:
<arg name="installed_paths" value="vendor/your-standard"/>
Post-Install Scripts
phpunit):
"scripts": {
"test": ["@install-codestandards", "phpunit"]
}
CI/CD Optimization
vendor/ to avoid re-running the plugin on every build.^0.7.0+; older versions may need downgrading./) in installed_paths for cross-platform compatibility.How can I help you explore Laravel packages today?