
Composer是PHP的依赖项管理器,大约在8年前发布,今天发布了新版本2.0。多年来,Composer已获得许多新功能,并与PHP标准保持同步。第二个版本与较旧的项目兼容,但是将带来一些更强大的新功能。在本文中,我将向您详细介绍它们。
加速与优化
此版本中的性能已得到改进。现在,它不考虑已安装的软件包,因此更新速度更快。我们还改善了内存和处理器处理能力。
. vendor , , . .
, , , , , hirak/prestissimo, .

Composer . , Composer install/update .
, COMPOSER_DISABLE_NETWORK=1 :
COMPOSER_DISABLE_NETWORK=1 composer install. , .:
https://repo.packagist.org could not be fully loaded (Network disabled, request canceled: https://repo.packagist.org/packages.json), package information was loaded from the local cache and may be out of date, , :
The required git reference for gabrielanhaia/laravel-circuit-breaker is not in cache and network is disabled, aborting--dry-run “require” “remove”
(composer update --dry-run. , , , vendor.
Composer 2.* composer require composer remove
root
root , .
, , :
Do not run Composer as root/super user! See https://getcomposer.org/root for detailsComposer 2.* :
https://getcomposer.org/root for details
Continue as root/super user [yes]? , . , --no-interaction
composer install --no-interaction, . Composer 1.0 / . , ( ).
( ). , , packagist, .
, composer 2.x, . Composer 1.x , , , :
{
"repositories": [
{
"type": "composer",
"url": "https://example.org",
"canonical": false
}
]
}, , , , , .
, foo/bar some-vendor/ composer .:
{
"repositories": [
{
"type": "composer",
"url": "https://example.org",
"only": ["foo/bar", "some-vendor/*"]
}
]
} toy/package , , , .
{
"repositories": [
{
"type": "composer",
"url": "https://example.org",
"exclude": ["toy/package"]
}
]
} only, exclude , (*), .\
如果出于某种原因您想忽略任何特定的平台要求,则可以简单地运行以下命令: composer install --ignore-platform-req php
它将跳过PHP或特定版本的要求。如果要忽略所有要求,则应使用以前版本中已经可用的命令 --ignore-platform-reqs
其他更新
有许多新的小功能和错误修复,提高了其可用性和质量。如果您想了解更多有关它们的信息,请查看Github发行说明。