Slow updating of composer dependencies, despite --prefer-dist flag
Factors that can slow down Composer:
As pointed out,
xdebug
can affect the performance of Composer. Runningcomposer diagnose
will also warn you about this.Running
update
instead ofinstall
. People too often just runupdate
constantly. This makes Composer go through the entire dependency resolving process, regardless of whether or not anything has changed. When you runinstall
, Composer takes the requirements directly from your .lock file, skipping the dependency resolving process. You should only runupdate
during the development lifecycle of your application. And even then, it's not something you have to run daily usually.If you have a specific dependency that you update frequently yourself, you could try simplifying the process by running
composer update vendor/package --with-dependencies
instead.Setting
minimum-stability
todev
. This greatly expands the amount of possibilities that the dependency resolver has to consider. You should almost never lower theminimum-stability
todev
unless you absolutely have no other choice. Look into alternatives, such as temporarily using a inline@dev
flag.
This problem is often related to xdebug being loaded in your CLI environment. (It doesn't matter if xdebug is enabled or not.)
You can check whether xdebug is enabled using one of the followinc commands.
// Unix
php -m | grep xdebug
// Windows
php -m | findstr xdebug
Further information on what operations take so long can be gained by enabling maximum verbosity and profiling information. (Replace install with update if you are updating the packages.)
composer install --prefer-dist -vvv --profile