Fix Composer require/update slowness

There are many reasons by which the composer require/update takes too long to complete the operation. Let’s see how you can fix this issue:

1. Disable XDebug. Check if the XDebug is causing problems by running:

composer --version
sudo phpdismod -s cli xdebug

2. Add GitHub Dev and Tags key. You can get GitHub keys from here: https://composer.github.io/pubkeys.html

composer diagnose
composer self-update --update-keys

3. Update GitHub access token to access public repos faster
Create GitHub personal access token here: https://github.com/settings/tokens/new
Description: composer
Select Scopes: repo > public_repo (Only allow accessing public repositories)

Update token by running:

composer config -g github-oauth.github.com token

Check the token here: /home/<user>/.config/composer/auth.json

4. Adding secure packagist domain name
https is faster then http for packagist. You can update the packagist URL by running:

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

5. Global require hirak/prestissimo
This package has been claimed to increase composer speed up to 10 times faster

composer global require hirak/prestissimo

That’s it, enjoy 🙂