- How do I install dealerdirect/phpcodesniffer-composer-installer in a Laravel project?
- Install it as a development dependency with composer require --dev dealerdirect/phpcodesniffer-composer-installer:"^1.0". Composer 2.2+ will ask for plugin permission; grant it or run composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true. No service provider or Laravel configuration is needed.
- Do I need this plugin if my Laravel app uses Pint instead of PHP_CodeSniffer?
- No. A default Laravel install ships Pint, which wraps PHP-CS-Fixer, and this plugin only matters when your team standardizes on PHP_CodeSniffer and consumes external rulesets. If you maintain a single in-repo ruleset, phpcs.xml with a config name="installed_paths" entry covers it without the plugin.
- Why does Composer ask for permission to run this plugin?
- Since Composer 2.2, plugins that execute code during install/update require explicit consent. The plugin must be allowed in config.allow-plugins to register PHPCS standards; if permission is denied, dependency installation can still succeed but standards will not be registered. Add the allow-plugins flag via Composer config or a reviewed composer.json change.
- Which PHP and Composer versions does this plugin require in a Laravel project?
- The plugin requires PHP 7.2 or newer and Composer 2.2 or newer, and it supports PHP_CodeSniffer 3.x and 4.x. Laravel 10, 11, and 12 baselines satisfy those floors, but pinned legacy CI images or older Docker bases should be checked. The plugin is not tied to a specific Laravel version.
- How does the plugin register Composer-installed coding standards with PHP_CodeSniffer?
- On install/update events it searches installed Composer packages for phpcodesniffer-standard packages, including the project itself, and scans them for rulesets. It then calls PHP_CodeSniffer to configure the installed_paths option. That removes manual symlinking, repository checkouts, and phpcs config edits.
- Why am I getting phpcs: Unrecognized standard after installing a ruleset via Composer?
- The most common cause is that the installer plugin did not run: missing allow-plugins approval, CI using --no-plugins, or a global Composer install shadowing the local plugin. Check that Composer did not skip the plugin, then verify the standard is actually discovered. For deterministic CI, invoke Plugin::run from a Composer script as documented. Also confirm nested rulesets are within the default search depth or adjust extra.phpcodesniffer-search-depth.
- Can I use this plugin with Composer install --no-plugins in CI?
- The plugin cannot register standards if Composer runs with --no-plugins, because plugin code is not executed. The README documents invoking Plugin::run from Composer scripts for environments that need explicit re-registration or deterministic setup. Otherwise, allow the plugin in CI and avoid --no-plugins for the install step that should register PHPCS standards.
- Does this package add runtime overhead to a Laravel application?
- No. It is a Composer install-time plugin that writes PHP_CodeSniffer's installed_paths setting and contributes no application runtime code. It should be a require-dev dependency and is excluded from production builds installed with --no-dev. It does not add a Laravel service provider or touch application configuration.
- What alternatives exist to dealerdirect/phpcodesniffer-composer-installer?
- You can manually set installed_paths in phpcs.xml, symlink or check out ruleset repositories, or rely on Composer path repositories. For one in-repo ruleset with no external dependencies, a phpcs.xml config entry is the simplest baseline. The plugin pays off when you consume multiple external standards such as slevomat/coding-standard, PHPCompatibility, or WordPress Coding Standards.
- Is dealerdirect/phpcodesniffer-composer-installer actively maintained and ready for PHP_CodeSniffer 4?
- Yes. It is MIT-licensed, maintained under PHPCSStandards, has recent releases, and supports both PHP_CodeSniffer 3.x and 4.x, so the PHPCS 4 migration does not force a coordinated plugin upgrade. Reported star counts and Dependents: 0 understate its real-world role as the de facto PHPCS ruleset installer. Validate adoption in your own project with composer why and a lockfile audit.