Why does it take up to two minutes for my composer dependencies to update, even when there have been no changes?
A popular suggestion is to append the --prefer-
I had a problem due to having IPv6 enabled. Running the following fixed this problem:
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
You can find more information here: https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues-
Factors that can slow down Composer:
As pointed out, xdebug
can affect the performance of Composer. Running composer diagnose
will also warn you about this.
Running update
instead of install
. People too often just run update
constantly. This makes Composer go through the entire dependency resolving process, regardless of whether or not anything has changed. When you run install
, Composer takes the requirements directly from your .lock file, skipping the dependency resolving process. You should only run update
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
to dev
. This greatly expands the amount of possibilities that the dependency resolver has to consider. You should almost never lower the minimum-stability
to dev
unless you absolutely have no other choice. Look into alternatives, such as temporarily using a inline @dev
flag.
You are using a private repository. This will not allow to download zipped version of the version you include, but must clone the repository. Additionally, it might be that the whole repository must be scanned to find the required version.
You should check whether using Satis is an option. That way you could prepare ZIPs of your own software and download it just like the things hosted on Github (which has an API for this that is used by Composer to allow downloading ZIPs even if they are not explicitly prepared).
Seems like the problem was resolved, but this might help someone.
Whenever I ran composer install or update, it took more than 10 seconds just to fetch the https://packagist.org/packages.json file. Eventually I found out that the problem was related to IPv6, since fetching files from IPv4 sites took less than a second.
The problem is that my ISP doesn't support IPv6, but I had it enabled in my ethernet properties. After I unticked Internet Protocol Version 6 (TCP/IPv6)
in my network settings, install/update speeds drastically improved (dropped from 200+ seconds to like 10)
I was having this issue while running Symfony2 on a VM that had low memory. I increased the machine's memory and it improved drastically. You may check the memory on your system and see if it can be upgraded.
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