phpstan / extension-installer
用于自动安装PHPStan扩展的Composer插件
1.4.3
2024-09-04 20:21 UTC
Requires
- php: ^7.2 || ^8.0
- composer-plugin-api: ^2.0
- phpstan/phpstan: ^1.9.0 || ^2.0
Requires (Dev)
- composer/composer: ^2.0
- php-parallel-lint/php-parallel-lint: ^1.2.0
- phpstan/phpstan-strict-rules: ^0.11 || ^0.12 || ^1.0
README
用于自动安装PHPStan扩展的Composer插件。
动机
diff --git a/phpstan.neon b/phpstan.neon index db4e3df32e..2ca30fa20a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,12 +1,3 @@ -includes: - - vendor/phpstan/phpstan-doctrine/extension.neon - - vendor/phpstan/phpstan-doctrine/rules.neon - - vendor/phpstan/phpstan-nette/extension.neon - - vendor/phpstan/phpstan-nette/rules.neon - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon - - vendor/phpstan/phpstan-strict-rules/rules.neon - parameters: autoload_directories: - %rootDir%/../../../build/SlevomatSniffs diff --git a/composer.json b/composer.json index 1b578dd624..f6ebf6e477 100644 --- a/composer.json +++ b/composer.json @@ -142,6 +142,7 @@ "jakub-onderka/php-parallel-lint": "1.0.0", "justinrainbow/json-schema": "5.2.8", "ondrejmirtes/mocktainer": "0.8", + "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.11.7", "phpstan/phpstan-doctrine": "^0.11.3", "phpstan/phpstan-nette": "^0.11.1",
用法
composer require --dev phpstan/extension-installer
从Composer 2.2.0版本开始,您将看到以下提示
phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org.cn/allow-plugins
Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]
使用 y
响应以允许插件。
扩展开发者的说明
对于此插件能够识别并能在Packagist上找到(可选但推荐)最好将扩展的composer包类型设置为phpstan-extension
。
在扩展的composer.json
文件的extra
部分添加phpstan
键
{ "extra": { "phpstan": { "includes": [ "extension.neon" ] } } }
忽略特定的扩展
您可能想要禁用特定扩展的自动安装以手动处理安装。在composer.json
中添加一个extra.phpstan/extension-installer.ignore
数组来忽略特定的扩展,该数组指定要忽略的包列表。
{ "extra": { "phpstan/extension-installer": { "ignore": [ "phpstan/phpstan-phpunit" ] } } }
限制
扩展安装器依赖于Composer脚本事件,因此您不能使用--no-scripts
标志。