Speed up composer!

Are you experiencing slow composer update? Well there is a solution!

After some google research I have found to Fixes!

Let’s start with some benchmarks

Benchmarks – Small Json

Before every test I have executed composer cache:clear so the results don’t cheat by using the cache!

I have just this Test composer

before no cache:
442.9MiB/163.16s

after no cache and fix 1:
442.9MiB/128.23s

after no cache and fix 1 + 2:
452.9MiB/33.39s

Benchmarks – Magento Create Project

Yeah this is an interesting part!

before no cache:
807.6MiB/1106.23s

after no cache and fix 1 + 2:
817.6MiB/268.46s

That’s a big difference!!!!

Fix 1

Yeah this is the part were you all have been waiting for!

Change the IP which you use for packagist.org I use this one now 54.37.4.73 and it is very fast!

Just add the following line to your /etc/hosts (when you have MacOS)

54.37.4.73 packagist.org

More information about this you can find in this old article in which the IPs are no longer the same
source: https://medium.com/@matriphe/how-to-speed-up-php-composer-629bed0d9b15

Fix 2

Start using prestissimo a composer plugin. This is a composer plugin that downloads packages in parallel to speed up the installation process.

Easy to install by running composer global require hirak/prestissimo
source: https://github.com/hirak/prestissimo

And now you are all set!