1. require command
Add new dependency packages to composer.json
files 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.lock
a 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.lock
file, composer will create it after handling dependencies.