我正在使用作曲器,并且我刚刚更新了guzzlehttp/guzzle
。我为安装的软件包感到惊讶:
>composer update guzzlehttp/guzzle
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 1 update, 0 removals
- Installing symfony/polyfill-php72 (v1.17.0): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.17.0): Downloading (100%)
- Installing symfony/polyfill-intl-idn (v1.17.0): Downloading (100%)
- Updating guzzlehttp/guzzle (6.5.2 => 6.5.4): Downloading (100%)
我正在使用安装了mbstring
的php 7.4,并且没有理由安装这些polyfills。 Composer知道我正在使用的PHP版本:
>composer show --platform
(...)
ext-mbstring 7.4.2 The mbstring PHP extension
(...)
php 7.4.3 The PHP interpreter
我怀疑我在某处配置不当,对我来说这些安装了polyfills没有意义。
已安装polyfills [[万一]]程序包已安装在不符合要求的服务器中。这样可以实现最大的可移植性和兼容性。如果您知道您的项目已经依赖于特定的平台版本和/或扩展,那么避免安装这些软件包的方法可以确定在每次部署中始终可以使用它们,因此可以在[ C0]部分:
这将完全阻止安装这些软件包。但这不能确保在安装应用程序时存在这些功能。为了完整起见,您应该在require部分中添加相应的条目:
replace
这在"replace": {
"symfony/polyfill-php72": "*",
"symfony/polyfill-mbstring": "*",
}
自述文件中有所介绍,但仅提及PHP版本的polyfill,尽管相同的逻辑适用于您项目中的任何其他polyfill肯定具有不需要的足够功能,并且可以避免安装总共。
仍然,如果您执行
not
这样做,则对性能的影响很小,不应引起关注。