Alexandre Debril

web programmer & open source contributor

How to fix Composer's slowness

You may have notice that Composer can get really, reaally slow on some setups. This is the case at my office, so I tried to find a solution. Let's run Composer in very verbose mode :

$ composer -vvv require phpunit/phpunit
Reading ./composer.json
Loading config file ./composer.json
Checking CA file /etc/ssl/certs/ca-certificates.crt
Downloading https://packagist.org/packages.json
Writing /root/.composer/cache/repo/https---packagist.org/packages.json into cache
Downloading http://packagist.org/p/provider-2013%24fabc3be20d24d6af724445e1f9f6cf7a891f5e0d752c3ee50e5de928877bf21e.json

And it seems to get stuck here. In fact, it's not. If you wait for a little while (let's say, 2 or 3 minutes), Composer stores the file in cache and downloads the next provider-*.json file. Which takes 3 more minutes and Composer won't finish its downloads soon because, it will download more than 10 files after that.

But Google is great and it gave me the solution :

$ composer config --global repo.packagist composer https://packagist.org

And now it runs fast. Just because sometimes, Packagist is slow through HTTP without SSL.

Please note : PHP must support SSL for this to work.