Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a single library with Composer?

I need to install only 1 package for my SF2 distribution (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?

like image 783
Tool Avatar asked May 24 '13 16:05

Tool


People also ask

How do I update a single package on composer?

To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer.json file) and update the lock file with the new versions.

How do I update my composer update?

update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.


2 Answers

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

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

then to update only this single package:

composer update doctrine/doctrine-fixtures-bundle 
like image 192
Nicolai Fröhlich Avatar answered Nov 25 '22 01:11

Nicolai Fröhlich


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-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.
like image 44
Yosvel Quintero Arguelles Avatar answered Nov 25 '22 00:11

Yosvel Quintero Arguelles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!