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
{
"name": "mrlewis/test",
"description": "Composer test",
"type": "project",
"require": {
"monolog/monolog": "^1.23",
"doctrine/instantiator": "^1.1",
"symfony/console": "^4.0",
"symfony/debug": "^4.0",
"doctrine/annotations": "^1.6",
"doctrine/dbal": "^2.7",
"doctrine/inflector": "^1.3",
"guzzlehttp/guzzle": "^6.3",
"sebastian/exporter": "^3.1",
"symfony/process": "^4.0",
"doctrine/cache": "^1.7",
"symfony/routing": "^4.0",
"symfony/var-dumper": "^4.0",
"nesbot/carbon": "^1.26"
},
"require-dev": {
"phpunit/phpunit": "^7.1",
"fzaninotto/faker": "^1.7"
},
"config": {
"sort-packages": true
}
}
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!