compoesr
#/
update can update the specified dependency package (upgrade/downgrade).
require is more flexible. If it is not installed, it will be installed. If it is installed, it will
upgrade or
downgrade according to the passed version number.
update cannot pass the specified
version number on the command line. You need to manually edit
composer.json first and specify the new
version number. , and then execute the update command.
#忽略 composer require google/protobuf --ignore-platform-reqs -vvv
// 安装包 composer require hashids/hashids:2.0.0 // 已安装 升级 composer require hashids/hashids:3.0.0 // 已安装 降级 composer require hashids/hashids:2.0.4
updatecommand Unable to specify
package version on the command line No., you need to manually modify the
composer.json file
// 安装包 composer require hashids/hashids:2.0.0
composer update hashids/hashids:3.0.0
vim composer.json "require": { "hashids/hashids": "3.0.0" }, :wq #升级到3.0.0 composer update hashids/hashids vim composer.json "require": { "hashids/hashids": "2.0.4" }, :wq #降级到2.0.4 composer update hashids/hashids
composer update package1
composer update package2
composer update package3 method to update sequentially, because
composer will verify the integrity of the configuration file
json vs lock, you specified that you want me to update
A, but you
B's
version is inconsistent in
json and
lock, but you don't want me to update it. This is problematic.
composer update to update dependencies globally. Note that it is an update operation for global packages. Some packages that you have not changed but use a version number range may also be updated and upgraded. Please Use with caution!
install can be used to install dependencies for the first time after the project is initialized, and the version number in
composer.lock will be read first , to ensure the consistency of package versions in collaborative development as much as possible. The package version record that exists in
composer.lock is equivalent to executing
composer require packageName:versionNo, and the one that does not exist is equivalent to executing
composer update packageName with versionRule in composer.json.
composer.lock/composer.json, and A uploads it to the warehouse. After B is pulled to the local,
composer install should be executed once to synchronize the team's version changes.
composer.lock/composer.json to the remote warehouse at the same time.
大于/大于等于:>1.2.3 >=1.2.3
小于/小于等于:<1.2.3 <=1.2.3
确切的版本号:1.2.3
~1.2.3: 1.2.3 <= version < 1.3
^1.2.3: 1.2.3 <= version < 2.0
{
"php": ">=7.0",
"ext-swoole": ">=4.0.0",
"lib-curl": ">=7.29.0"
}
Copy after login
大于/大于等于:>1.2.3 >=1.2.3 小于/小于等于:<1.2.3 <=1.2.3 确切的版本号:1.2.3 ~1.2.3: 1.2.3 <= version < 1.3 ^1.2.3: 1.2.3 <= version < 2.0 { "php": ">=7.0", "ext-swoole": ">=4.0.0", "lib-curl": ">=7.29.0" }