Why is PHP Composer so slow when all I do is init a project with zero dependencies? Here are the commands I run:
composer init
<step through composer.json creation, define 0 zero dependencies>
composer install
Wait 3 minutes (not an exaggeration).
All composer has to do is pull in an autoloader and create /vendor
, so why does it take so long? For that matter, why doesn't that step happen on composer init
?
Is there a configuration option I can use to pull in a cached autloader and vendor upon init
?
Composer update is very slow if you have a lot of dependencies/packages implemented. You should avoid variable versions and think about using a HHVM as server.
Always composer update on your dev machine first, test it and if all test are valid deploy the composer. lock to your production environment and run composer install there. Now composer installes exactly the versions you tested before, even if there are newer (but untested) ones.
Go nuclear. Clear your cache, remove the vendor directory and lockfile, and do a composer update.
Because Composer is implemented by file_get_contents()
. That has no TCP optimizations, no Keep-Alive, no multiplexing, etc.
I created a Composer plugin to download packages in parallel: https://packagist.org/packages/hirak/prestissimo
$ composer global require hirak/prestissimo
Please try it. In my environment, composer install
becomes 10 times faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With