ArticlesNews & Events

Composer V 2.0 is now available!

Composer V 2.0 is now available!

Composer version 2 is now available, this a good update for PHP developers as the new the version comes with a lot of performance improvements over the previous version.

Composer 2.0 Changelog

  • Many CPU and memory performance improvements
  • The update command is now much more deterministic as it does not take the already installed packages into account
  • Package installation now performs all network operations first before doing any changes on disk, to reduce the chances of ending up with a partially updated vendor dir
  • Partial updates and require/remove are now much faster as they only load the metadata required for the updated packages
  • Added a platform-check step when vendor/autoload.php gets initialized which checks the current PHP version/extensions match what is expected and fails hard otherwise. Can be disabled with the platform-check config option
  • Added a Composer\InstalledVersions class which is autoloaded in every project and lets you check which packages/versions are present at runtime
  • Added a composer-runtime-api virtual package which you can require (as e.g. ^2.0) to ensure things like the InstalledVersions class above are present. It will effectively force people to use Composer 2.x to install your project
  • Added support for parallel downloads of package metadata and zip files, this requires that the curl extension is present and we thus strongly recommend enabling curl
  • Added parallel installation of packages (requires OSX/Linux/WSL, and that unzip is present in PATH)
  • Added much clearer dependency resolution error reporting for common error cases
  • Added support for updating to a specific version with partial updates, as well as a –with flag to pass in temporary constraint overrides
  • Added automatic removal of packages which are not required anymore whenever an update is done, this will purge packages previously left over by partial updates and require/remove
  • dded support for TTY mode on Linux/OSX/WSL so that script handlers now run in interactive mode
  • Added only, exclude and canonical options to all repositories, see repository priorities for details
  • Added support for many new lib-* packages in the platform repository and improved version detection for some ext-* and lib-* packages
  • Added pre-operations-exec event to be fired before the packages get installed/upgraded/removed
  • Added pre-pool-create event to be fired before the package pool for the dependency solver is created, which lets you modify the list of packages going in
  • Added post-file-download event to be fired after package dist files are downloaded, which lets you do additional checks on the files
  • Added –locked flag to show command to see the packages from the composer.lock file
  • Added –unused flag to remove command to make sure any packages which are not needed anymore get removed
  • Added –dry-run flag to require and remove commands
  • Added –no-install flag to update, require and remove commands to disable the install step and only do the update step (composer.lock file update)

Refer to this link to list the complete composer 2.0 changelog.

How to upgrade?

  • Composer 2.0 still supports PHP 5.3 and above, much like Composer 1.x
  • composer.lock files are interoperable between versions, so you can upgrade to 2.0 and roll back easily if needed.
  • Most commands and arguments remain the same, and largely what you know about Composer remains true in 2.0.

If you run composer self-update from 1.x, it will warn you that a new stable major version of Composer is available, and you can use composer self-update --2 to migrate to it.

Should you encounter issues, you can go back at any time by using composer self-update --1. Hopefully that will make everyone feel comfortable to experiment with the new release.

If you are installing Composer automatically from the installer script, and wish to remain on Composer 1.x for the time being, you can also pass it a --1 argument to prevent it from installing Composer 2.0 by default. If you do this please remember and aim to upgrade in a timely manner, as Composer 1.x will not be maintained for very long.

Seeing Command "self-update" is not defined. ? If you installed Composer via your OS package manager, the self-update command may not be available. Use which composer to find its path (e.g. /usr/bin/composer), then run the install script adding --install-dir /usr/bin --filename composer (adjusting the install dir to match your path) to the php composer-setup.php line.

0 0 votes
Article Rating

What's your reaction?

Not Sure

You may also like

Notify of
Inline Feedbacks
View all comments