composer-php - Composer 的 `require` 命令的目的是什么

标签 composer-php

以下是文档中的定义:

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 installcomposer 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/

相关文章:

php - Composer : can't create new project

macos - 尝试在 Mac OS X 10.7.5 上的 usr/local/bin 中安装 composer

php - PHP : no connection 中的 Propel 和 Composer

laravel - Composer 卡在 4.2 上的 "Resolving dependencies through SAT"

php - Composer 无法安装 Twig Extensions

Laravel 5 php artisan 未在 Vagrant 中运行,缺少供应商/services.json?

python - 我将如何使用 php 在网页上显示多个按钮(它们将控制 raspberry pi)

未找到 PHP Composer Autoloader 类异常

php - Laravel Composer 更新失败 Ubuntu

google-api - Symfony2 和 Google API 集成