Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I speed up composer installs?

We have to migrate a few hundred packages to composer, using VCS repository on GitHub and I noticed its even on root servers extreme slow, using a average app with 20 to 30+ packages. On home machines its even worst. In fact it makes the work really tedious and somehow unacceptable.

Are there any improvments which can be done to speed it up? Zip or packagist is not an option for us either.

like image 415
stackoverclan Avatar asked Jan 16 '15 15:01

stackoverclan


People also ask

How can I speed up my composer install?

Clear your cache, remove the vendor directory and lockfile, and do a composer update.

Why does composer update takes so long?

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.

Why is composer not installing?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

Should I install composer as root?

For this reason, it is strongly advised to avoid running Composer as super-user/root. All commands also dispatch events which can be caught by plugins so unless explicitly disabled installed plugins will be loaded/executed by every Composer command.


3 Answers

UPDATE: Now with Composer v2+ you don't need Prestissimo anymore. You can achieve better (incredible) speeds using this new version.


Use Prestissimo (only Composer v1-)

Prestissimo is a global Composer plugin that installs dependencies in parallel. It is crazy fast. It’s worth noting that Prestissimo requires cURL, which may not work behind certain firewalls or proxies. I haven’t run into any issues at all personally.

like image 129
insign Avatar answered Sep 19 '22 03:09

insign


Making sure your composer.lock files are in version control and in your main project is critical for making composer install fast. It contains a list of packages and information about them (including specific versions) that Composer uses to speed up the installation process.

See https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file for further details.

like image 23
ceejayoz Avatar answered Sep 22 '22 03:09

ceejayoz


Two things I would try

1) Use the verbose option -v to see what's taking so long. It could be your internet bandwidth or latency, or something else surprising.

2) use the --no-dev and --prefer-dist options to prevent composer considering versions you aren't using in production.

Thirdly :) you could run a regular background composer update somewhere to keep the caches up to date. So at least your installs would be a bit quicker.

(Ps. I'm sure there was -v -vv and -vvv for levels of detail but I cannot see that in the docs now... I thought only the second level gave you download speeds.)

like image 43
scipilot Avatar answered Sep 19 '22 03:09

scipilot