我只需要为我的SF2发行版安装一个包(DoctrineFixtures)。

当我奔跑

php composer.phar update

我得到

  - Updating twig/twig (dev-master 39d94fa => v1.13.0)
    The package has modified files:
    M CHANGELOG
    M doc/filters/batch.test
    M doc/filters/index.rst
    M doc/filters/url_encode.rst
    M doc/functions/index.rst
    M doc/tags/index.rst
    M doc/tests/index.rst
    M lib/Twig/Autoloader.php
    M lib/Twig/Compiler.php
    M lib/Twig/CompilerInterface.php
-10 more files modified, choose "v" to view the full list

看来上一个开发人员在供应商内部编辑了很多文件。

为了解决这个问题,我试过了

php composer.phar update <package_name>

但这似乎并不奏效。如何从composer.json中更新/安装一个库?


当前回答

只使用

composer require {package/packagename}

like

composer require phpmailer/phpmailer

如果包不在供应商文件夹..Composer安装它,如果包存在,Composer将包更新到最新版本。

更新:

要求安装或更新最新的软件包版本。如果你想更新一个包,只需使用update。

其他回答

在2.1版本中安装doctrine/doctrine-fixture -bundle。*和最小稳定性@dev使用这个:

composer require doctrine/doctrine-fixtures-bundle:2.1.*@dev

然后只更新这个包:

composer update doctrine/doctrine-fixtures-bundle

您可以使用以下命令更新任何模块及其依赖项

composer update vendor-name/module-name --with-dependencies

你也可以按照下面的步骤来安装新包。

php composer.phar require

然后终端会要求你输入包的名称进行搜索。

$ Search for a package []: //Your package name here

然后终端会询问包的版本(如果你想要最新的版本,就把它留空)

$ Enter the version constraint to require (or leave blank to use the latest version) []: //your version number here

然后按回车键。终端会要求安装另一个软件包,如果你不想安装另一个,只要按回车键就可以了。

确保composer将已经安装的包更新到您在composer中设置的版本约束的最后一个版本。Json从供应商删除包,然后执行:

php composer.phar update vendor/package

只使用

composer require {package/packagename}

like

composer require phpmailer/phpmailer

如果包不在供应商文件夹..Composer安装它,如果包存在,Composer将包更新到最新版本。

更新:

要求安装或更新最新的软件包版本。如果你想更新一个包,只需使用update。