我只需要为我的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中更新/安装一个库?
如果你只是想更新一些包,而不是全部,你可以这样列出它们:
php composer.phar update vendor/package:2.* vendor/package2:dev-master
你也可以使用通配符一次更新一堆包:
php composer.phar update vendor/*
正如@ZeroThe2nd所评论的那样,ZSH用户可能需要将他们的供应商/*用引号括起来:
php composer.phar update "vendor/*"
--prefer-source: Install packages from source when available.
--prefer-dist: Install packages from dist when available.
--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.
--dry-run: Simulate the command without actually doing anything.
--dev: Install packages listed in require-dev (this is the default behavior).
--no-dev: Skip installing packages listed in require-dev. The autoloader generation skips the autoload-dev rules.
--no-autoloader: Skips autoloader generation.
--no-scripts: Skips execution of scripts defined in composer.json.
--no-plugins: Disables plugins.
--no-progress: Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters.
--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.
--lock: Only updates the lock file hash to suppress warning about the lock file being out of date.
--with-dependencies: Add also all dependencies of whitelisted packages to the whitelist.
--prefer-stable: Prefer stable versions of dependencies.
--prefer-lowest: Prefer lowest versions of dependencies. Useful for testing minimal versions of requirements, generally used with --prefer-stable.
你也可以按照下面的步骤来安装新包。
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.json
"parsecsv/php-parsecsv": "0.*"
作曲家。锁文件
"name": "parsecsv/php-parsecsv",
"version": "0.1.4",
最新版本是1.1.0。最新的0。*版本为0.3.2
安装:composer Install parsecsv/php-parsecsv
这将安装锁文件中指定的0.1.4版本
更新:composer Update parsecsv/php-parsecsv
这将把包更新到0.3.2。关于你的composer.json的最高版本。作曲家的词条。锁将被更新。
Require: composer Require parsecsv/php-parsecsv
这将更新或安装最新版本1.1.0。你的作曲家。锁定文件和编写器。Json文件也将被更新。