I live in a lovely developing country, Indonesia. Internet is still an expensive thing and bandwidth is not so high among other nearby countries. You can find the comparison below.
Being web developer, especially PHP, having always available internet connection is an important thing. Push the code to repository, upload the files to web server,
composer require <somephpscript>, etc. Sometimes, the connection is slow when accessing some area, like Europe or US East Coast. This could make my life hard, especially when I'm on tight deadline and the application needs many dependencies.
When above issue happens, I will lose many times just to wait for composer require/update process finished. Time is very precious thing we don't want to waste, right?
Investigation and Solution
First, I try to examine what really happens under the hood when I run
composer require command. I run:
composer --prefer-dist --verbose -vvv require guzzlehttp/guzzle
After quick check, I figured out that packagist.org is hosted in France. I also noticed the issue sometimes happens and sometimes not. When it happens I still have a good connectivity with gmail and VPS (my VPS is in US). My conclusion is it seems that my internet doesn't have a good connectivity to France.
I thought of creating a packagist.org mirror, but it seems there were no public mirror available. Thankfully, I found this article
The solution is to use a CDN based packagist URL:
https://packagist.jp, which can be done using this command:
composer config --global repositories.packagist composer https://packagist.jp