以下是文档中的定义:
The require command adds new packages to the composer.json file from the current directory. If no file exists one will be created on the fly. After adding/changing the requirements, the modified requirements will be installed or updated.
If you do not want to choose requirements interactively, you can just pass them to the command.
我似乎无法理解 require
命令的用途以及与 install
的区别。您能详细说明一下吗?
这是使用该命令的示例:
composer global require "fxp/composer-asset-plugin:~1.0.3"
你能告诉我有什么区别吗:
composer global install "fxp/composer-asset-plugin:~1.0.3"
最佳答案
这只是一个约定。其他命令可能会有一些针对普通人误用的回退,但每个命令都针对不同的功能进行了优化。这只是更好的用户体验。
composer install
和 composer update
的相似性也是如此。
至于约定,按照常见工作流程的顺序:
-
composer install
用于安装新应用的所有包(全部在composer.json
中提到),使用:composer install
-
composer require
用于添加新包,使用:composer require symfony/symfony
composer update
用于更新当前依赖项,使用:composer update
关于composer-php - Composer 的 `require` 命令的目的是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33449057/