I am sure, each one of us have been in the situation when the
composer require command just takes too long to install/require a package. Well, it was my turn today and I thought to share the solution for it.
I figured out the problem by using the "-vvv" flag with the
composer require command. Using the "-vvv" flag we can view and monitor what the command is actually executing and where it gets stuck.
It usually gets stuck while downloading the 'provider- * ' json files. I noticed that it downloads those files through packagist's url (https://packagist.com). I changed the mirror and updated the
repo.packagist by executing the following command:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
That solved the slowness of the composer require command for me. If you are aware of any other possible & more better solutions, you can correct me with those on twitter