cevinio / production-dependencies-guard
防止将开发包添加到require-section(应该是require-dev)
dev-main
2024-03-26 14:15 UTC
Requires
- php: >=8.0
- composer-plugin-api: ^1.0|^2.0
- ext-json: *
Requires (Dev)
- ext-xdebug: *
- composer/composer: ^1.0|^2.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.2
- infection/infection: ^0.26
- phpcompatibility/php-compatibility: ^9.3
- phpunit/phpunit: ^9.5
- rregeer/phpunit-coverage-check: ^0.3
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-26 15:22:45 UTC
README
防止将开发包添加到require
,从而进入生产环境。在实际情况中,防止例如调试工具栏部署到生产环境中。
此外,您可以配置守护程序以拒绝缺失/不合适的许可证、废弃的或描述中提到debug
的包,并根据composer.lock(更深入的分析)分析包。
由于原版已不再维护,因此从kalessil/production-dependencies-guard分支此仓库。
感谢Vladimir Reznichenko创建原始的生产依赖守护程序。
安装
composer require --dev cevinio/production-dependencies-guard:dev-main
配置
可以在顶级composer.json文件中启用额外的守护程序检查
{
"name": "...",
"extra": {
"production-dependencies-guard": [
"check-lock-file",
"check-description",
"check-license",
"check-abandoned",
"white-list:vendor/package-one",
"white-list:vendor/package-two:abandoned,description",
"accept-license:MIT",
"accept-license:proprietary"
]
}
}
white-list:<package>
将包添加到白名单,即使违反规则也不会报告white-list:<package>:<guard>,...
仅将包添加到指定守护程序的白名单中check-lock-file
使用composer.lock而不是composer.json,允许更深入的依赖关系分析check-description
启用描述和关键词分析(搜索debug
),允许检测自定义开发包check-abandoned
启用废弃包检查check-license
启用许可证检查(包必须提供许可证信息)accept-license:<license>
指定应接受的许可证(如果省略设置,则包括专有许可证)
使用方法
当包被添加到composer.json
文件的require-dev部分("cevinio/production-dependencies-guard": "dev-main"
)时,它将防止将开发包添加到require
部分。由于开发包没有安全保证(不是用于生产使用,仅用于开发目的),这也提高了您应用程序的安全性。
composer require --dev cevinio/production-dependencies-guard:dev-main
composer require phpunit/phpunit:*
# it should be `composer require --dev phpunit/phpunit:*` here
将运行错误(有利可图)
./composer.json has been updated
Installation failed, reverting ./composer.json to its original content.
[RuntimeException]
Dependencies guard has found violations in require-dependencies (source: manifest):
- phpunit/phpunit: dev-package-name
稳定性
此包仅以其dev-main
版本提供:根据包的目的。