Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why updating of dependencies in composer is so slow?

I am using composer (http://getcomposer.org/) to manage installed bundles in the Symfony2 (symfony v 2.1.3). Version of the composer is de3188c.

I have problem that when I add new bundle into the composer.json and execute it the time to show messages about Updating dependencies and next downloading them all is very low.

I have this data in the composer.json (see below) and the executing time is approximately 20 MINUTES!!! The internet connection is fast enough I can download big files very fast...

Is there any trick to make it faster?

{ "name": "symfony/framework-standard-edition", "description": "The \"Symfony Standard Edition\" distribution", "autoload": {     "psr-0": { "": "src/" } }, "require": {     "php": ">=5.3.3",     "symfony/symfony": "2.1.*",     "doctrine/orm": ">=2.2.3,<2.4-dev",     "doctrine/doctrine-bundle": "1.0.*",     "twig/extensions": "1.0.*",     "symfony/assetic-bundle": "2.1.*",     "symfony/swiftmailer-bundle": "2.1.*",     "symfony/monolog-bundle": "2.1.*",     "sensio/distribution-bundle": "2.1.*",     "sensio/framework-extra-bundle": "2.1.*",     "sensio/generator-bundle": "2.1.*",     "jms/security-extra-bundle": "1.2.*",     "jms/di-extra-bundle": "1.1.*",     "doctrine/doctrine-fixtures-bundle": "dev-master",     "webignition/doctrine-migrations-bundle": "dev-master" }, "scripts": {     "post-install-cmd": [         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"     ],     "post-update-cmd": [         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",         "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"     ] }, "minimum-stability": "dev", "extra": {     "symfony-app-dir": "app",     "symfony-web-dir": "web" } 
like image 574
Myth Rush Avatar asked Nov 16 '12 09:11

Myth Rush


People also ask

Why does composer update take so long?

People too often just run update constantly. This makes Composer go through the entire dependency resolving process, regardless of whether or not anything has changed. When you run install , Composer takes the requirements directly from your . lock file, skipping the dependency resolving process.

How can I speed up my composer update?

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

Why is composer so slow?

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.

How do I update dependency in composer?

Updating dependencies to their latest versions# To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer. json file) and update the lock file with the new versions.


2 Answers

Try to specify a version for each dependency in composer.json and use the option --prefer-dist when calling composer. It will download ZIP files from the repositories (if available) instead of the single files.

php composer.phar install --prefer-dist 
like image 165
Roberto Avatar answered Nov 15 '22 14:11

Roberto


Since you accepted an answer, it looks like that solved your problem. Just in case anybody else stumbles across this question though (like I did when I was searching), in my case, a really slow Composer install had to do with my PHP version (word of warning, I am a complete and utter Composer newbie), even though Composer ran through its standard checks and said everything was fine. I run Ubuntu 12.04 LTS and was too lazy to upgrade from the default PHP 5.3.10 (the same version you're running) in the Precise repo.

Installing Twig via Composer originally took me around 30 minutes. I gave up installing Doctrine after it took more than an hour. I upgraded to 5.4.17 (using this PPA https://launchpad.net/~ondrej/+archive/php5) and installing Doctrine was done in a matter of seconds.

like image 38
badcook Avatar answered Nov 15 '22 14:11

badcook