The difference between composer require, install and update

1. require command

Add new dependency packages to composer.jsonfiles in the current directory.

grammar:


composer require [package:version]

选项参数:
	package: 包名
	version: 版本号

2. update command

To get the latest versions of dependencies and update the composer.lock file, you should use the update command. This will resolve all of the project's dependencies and write the exact version numbers composer.lock.

grammar:


composer update [package]

选项参数:
	package: 包名

3. install command

The install command reads files from the current directory composer.json, handles dependencies, and installs them into the vendor directory.

grammar:


composer install

Note: If there is 存在 composer.locka file in the current directory, it will read the dependency version from this file instead of obtaining the dependency from the composer.json file. This ensures that every consumer of the library gets the same dependency version. If 没有 composer.lockfile, composer will create it after handling dependencies.

Guess you like

Origin blog.csdn.net/change_any_time/article/details/129068893