How to Speed Up PHP Composer

Every PHP developer depends on Composer. Being the one and only dependency manager in PHP community sometime brings some performance issues.

Slowness is my biggest headache in this case. I know, this might caused by multiple factor, but I assume the problem is in my internet connection.

I have an OpenVPN server located in Singapore, and when I use the VPN, the Composer run fast. If I switch off the VPN, it takes forever.

After searching around, I found a good solution to speed up the Composer.

Use as your’s IP address

Packagist ( using two IP addresses (located in Belgium) and (located in Canada).

In Indonesia, will be resolved to

I tried to compare these two IP addresses using MTR.

tracing node to
tracing node to

From those mtr results, we could see that tracing to is less hop than to

I tried by forcing resolver to this IP address by editing /etc/hosts (I’m on OSX).

After confirming that the is resolved to using ping, I use composer update --profile to see if it makes changes.

I use this composer.json for the test.

"name": "matriphe/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"
"license": "MIT",
"authors": [
"name": "Muhammad Zamroni",
"email": ""
"config": {
"sort-packages": true

Here’s the result. Using took 205.68 seconds and using took only 42.5 seconds! It’s almost 5 times faster!

If you feel your composer is very slow, try to use as your IP address.

This result, of course depends on where you are and the internet connection quality, but for my case, it really helped.

Updated: Use Prestissimo

I got this package from Nazieb’s response to this post. I tried the package and amazed with the result.

Using Prestissimo, it only took 7.81 seconds!

Of course, combining these two methods will speed up Composer!

Like what you read? Give Muhammad Zamroni a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.