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

Extension Installer Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Declarative extension management: Add extensions like 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.
  • CI/CD optimization: Run 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.
  • Custom extension discovery: For internal or third-party extensions not on Packagist, ensure their composer.json includes the extra.phpstan.includes array pointing to config files, and optionally set "type": "phpstan-extension" for better visibility.

Gotchas and Tips

  • --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.
  • Path resolution quirks: Relative paths in 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.
  • Ignoring extensions: To disable auto-inclusion (e.g., for manual control or conflicting extensions), add "phpstan/extension-installer": { "ignore": ["phpstan/phpstan-phpunit"] } to extra in composer.json. Useful for debugging or handling legacy extension setups.
  • Plugin version compatibility: Ensure 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.
  • Debugging tips: After updates, run 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.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport