如何使用Composer更新單個庫?

[英]How to update a single library with Composer?


I need to install only 1 package for my SF2 distribution (DoctrineFixtures).

我需要為我的SF2發行版安裝一個軟件包(DoctrineFixtures)。

When I run

當我跑

php composer.phar update

I get

我明白了

  - 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

It appears the last developer edited a lot of files inside vendor.

看來最后一位開發人員在供應商內編輯了很多文件。

In order to get around this, I tried

為了解決這個問題,我試過了

php composer.phar update <package_name>

But that doesn't seem to work. How can I update/install only one library from composer.json?

但這似乎不起作用。如何從composer.json更新/安裝一個庫?

4 个解决方案

#1


331  

To install doctrine/doctrine-fixtures-bundle with version 2.1.* and minimum stability @dev use this:

要安裝doctrine / doctrine-fixtures-bundle 2.1版。*和最小穩定性@dev,請使用:

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

then to update only this single package:

然后只更新這個包:

composer.phar update doctrine/doctrine-fixtures-bundle

#2


114  

If you just want to update a few packages and not all, you can list them as such:

如果您只想更新一些軟件包而不是所有軟件包,可以將它們列為:

php composer.phar update vendor/package:2.* vendor/package2:dev-master

You can also use wildcards to update a bunch of packages at once:

您還可以使用通配符一次更新一堆包:

php composer.phar update vendor/*
  • --prefer-source: Install packages from source when available.
  • --prefer-source:在可用時從源安裝包。
  • --prefer-dist: Install packages from dist when available.
  • --prefer-dist:在可用時從dist安裝軟件包。
  • --ignore-platform-reqs: ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these. See also the platform config option.
  • --ignore-platform-reqs:忽略php,hhvm,lib- *和ext- *要求並強制安裝,即使本地計算機不滿足這些要求。另請參閱platform config選項。
  • --dry-run: Simulate the command without actually doing anything.
  • --dry-run:模擬命令而不實際執行任何操作。
  • --dev: Install packages listed in require-dev (this is the default behavior).
  • --dev:安裝require-dev中列出的包(這是默認行為)。
  • --no-dev: Skip installing packages listed in require-dev. The autoloader generation skips the autoload-dev rules.
  • --no-dev:跳過在require-dev中列出的安裝包。自動加載器生成會跳過autoload-dev規則。
  • --no-autoloader: Skips autoloader generation.
  • --no-autoloader:跳過自動加載器生成。
  • --no-scripts: Skips execution of scripts defined in composer.json.
  • --no-scripts:跳過composer.json中定義的腳本的執行。
  • --no-plugins: Disables plugins.
  • --no-plugins:禁用插件。
  • --no-progress: Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters.
  • --no-progress:刪除可能會弄亂一些不處理退格字符的終端或腳本的進度顯示。
  • --optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.
  • --optimize-autoloader(-o):將PSR-0/4自動加載轉換為classmap以獲得更快的自動加載器。這建議特別適用於生產,但可能需要一些時間才能運行,因此默認情況下目前尚未完成。
  • --lock: Only updates the lock file hash to suppress warning about the lock file being out of date.
  • --lock:僅更新鎖定文件哈希以禁止關於鎖定文件過期的警告。
  • --with-dependencies: Add also all dependencies of whitelisted packages to the whitelist.
  • --with-dependencies:將白名單包的所有依賴項添加到白名單。
  • --prefer-stable: Prefer stable versions of dependencies.
  • --prefer-stable:首選穩定版本的依賴項。
  • --prefer-lowest: Prefer lowest versions of dependencies. Useful for testing minimal versions of requirements, generally used with --prefer-stable.
  • --prefer-lowest:首選最低版本的依賴項。用於測試最低版本的需求,通常與--prefer-stable一起使用。

#3


4  

You can basically do following one to install new package as well.

您基本上可以執行以下操作來安裝新軟件包。

php composer.phar require

then terminal will ask you to enter the name of the package for searching.

然后終端會要求您輸入要搜索的包的名稱。

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

Then terminal will ask the version of the package (If you would like to have the latest version just leave it blank)

然后終端會詢問包的版本(如果您想要最新版本,請將其留空)

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

Then you just press the return key. Terminal will ask for another package, if you dont want to install another one just press the return key and you will be done.

然后你只需按返回鍵。終端會要求另一個包裹,如果您不想再安裝另一個包裹,只需按回車鍵即可完成。

#4


2  

To ensure that composer update one package already installed to the last version within the version constraints you've set in composer.json remove the package from vendor and then execute :

要確保作曲家將已安裝的一個軟件包更新到您在composer.json中設置的版本約束中的最后一個版本,請從供應商中刪除該軟件包,然后執行:

php composer.phar update vendor/package

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/05/24/724e86237ccd86e0fdb3388ac5f41dc4.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com