Reputation: 779
A composer install normally takes a few minutes. And on a production environment it's feels too slow. Is it possible to make a composer install to a temp directory and then switch it? If that is possible the downtime should be about zero.
Or are there any other way to do a composer install faster?
Upvotes: 17
Views: 7339
Reputation: 72226
You are asking two different and unrelated things.
Yes, it is a solution to build the next version of your site in a separate directory then put it in place after you moved the old version out of the way. It is, actually, the best solution.
This is how the deployment scripts I build work:
/var/www/new
); the following list of items and their order is not static, some projects need a different flow:
.gitignore
, IDE project files, placeholders etc);composer install
;mv
to move the entire directory (/var/www/html
to /var/www/old
, for example);mv /var/www/new /var/www/html
);vendor
and other files that do not change or are external).The advantages:
Regarding the other question, the only way I know to speed composer
up is to avoid running it using a PHP that loads the xdebug
extension. The xdebug
extension shouldn't be loaded on the production server anyway.
Upvotes: 2
Reputation: 4257
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
become 10 times faster.
Upvotes: 20
Reputation: 2869
You can sometimes speed up composer install
significantly by using the --prefer-dist
flag, which just happens to be recommended for production use:
--prefer-dist: Reverse of
--prefer-source
, composer will install from dist if possible. This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors.
composer install
docs here: http://getcomposer.org/doc/03-cli.md#install
Edited To Clarify Sometimes
I say it sometimes speeds up composer install
because there are plenty of factors that go into it feeling slow, not the least of which are network performance and the current Github status. A slow install can be really frustrating, but it's not always b/c of Composer.
Upvotes: 4