phpstan/extension-installer
Composer plugin that automatically discovers and installs PHPStan extensions, eliminating manual includes in phpstan.neon. Add it as a dev dependency, allow the plugin in Composer, and extensions can declare includes via extra.phpstan for auto-setup.
Install the package as a dev dependency:
composer require --dev phpstan/extension-installer
After installation, Composer will prompt to trust the plugin (answer y) to allow it to run during composer install/update. No further manual configuration is needed in composer.json for basic usage. To enable automatic extension detection, ensure your PHPStan config (phpstan.neon) uses %rootDir%-relative includes for extensions, or simply remove explicit includes: blocks referencing vendor paths. The plugin automatically generates a generated-config.php file under vendor/phpstan/extension-installer/ containing the aggregated extension includes—this is referenced implicitly by PHPStan when running commands.
phpstan/phpstan-doctrine, phpstan/phpstan-phpunit, etc., normally via composer require --dev. The installer will auto-detect them (especially if their composer.json defines "type": "phpstan-extension") and include their extension.neon/rules.neon files in the generated config.composer install --no-dev for production builds to avoid unnecessary plugin execution, but always include it in dev and CI environments. If committing vendor/, the generated config is tracked (via Git) to ensure consistency.composer.json includes the extra.phpstan.includes array pointing to config files, and optionally set "type": "phpstan-extension" for better visibility.--no-scripts breaks functionality: Never use composer install/update --no-scripts; the plugin relies on Composer’s script events to generate and update the config. Omitting scripts will cause extensions to be silently ignored.extra.phpstan.includes are resolved relative to the extension’s install path, not the project root—always use relative paths like extension.neon or rules.neon, not subdirectories unless explicitly intended."phpstan/extension-installer": { "ignore": ["phpstan/phpstan-phpunit"] } to extra in composer.json. Useful for debugging or handling legacy extension setups.phpstan/extension-installer >=1.4.0 for PHPStan ^2.0 and Composer 2.5+ compatibility; older versions may fail silently with newer Composer/PHPStan releases.phpstan --version to confirm config was regenerated; inspect vendor/phpstan/extension-installer/generated-config.php to verify included extensions. If extensions aren’t loading, check composer show phpstan/* to confirm type and extra metadata, and ensure no conflicting includes: blocks remain in phpstan.neon.How can I help you explore Laravel packages today?