69

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"
}
Reuben L.
  • 2,806
  • 2
  • 29
  • 45
Myth Rush
  • 1,088
  • 1
  • 9
  • 19
  • 1
    What you can do - is to specify needed tag (instead of 2.1.* use 2.1.1 f.e.) – Vitalii Zurian Nov 16 '12 at 09:34
  • In Early December 2014, an optimisation was found that stopped trying to garbage-collect memory during a Composer run. Because of some very specific things what were being done within Composer, it took a long time, but ultimately did very little. After the patch, many report that Composer will take more memory, but run in half, or even less time. – Alister Bulman Dec 16 '14 at 15:17
  • Also try updating composer. – Batandwa Sep 20 '17 at 18:00

5 Answers5

80

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
Roberto
  • 2,206
  • 4
  • 24
  • 31
  • It improves significantly the load time for my very simple project which has a lot of transitive dependancies (using phpunit) – Benoit Feb 05 '13 at 16:47
  • it also keeps a copy of the sit in ~/.composer so other projects, or updates etc will go there first. – Chris Sedlmayr May 01 '13 at 10:45
  • Seemed to be my problem exactly. When i just ran composer install without the lock-file it took like 30 minutes .. When i used the lock-file it was finished within seconds. – Benjamin Feb 10 '16 at 09:28
23

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.

badcook
  • 3,699
  • 14
  • 25
15

I have found that it is also very slow, in the tens of minutes slow.

For me I added -vvv and found it was hanging at stuff like Downloading https://packagist.org/p/provider-active$53cdf887c8d2925b3501f47d6980fb7bda2310716369bf7a84857c6e62bbab0f.json

I then went to the browser and tried to download that JSON file and sure enough. It was packagist.org to be the cause of the slowness.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
15

In my case, the above suggestions didn't make a difference. What did was to use the HTTPS protocol for packagist:

php composer.phar config --global repo.packagist composer https://packagist.org

or

composer config --global repo.packagist composer https://packagist.org

depending on your setup

Reuben L.
  • 2,806
  • 2
  • 29
  • 45
  • 3
    This worked perfectly for me. Would personally have marked this as the best answer. – Saintwolf Jun 29 '16 at 12:34
  • 1
    Worked perfectly for me – chadpeppers Sep 23 '16 at 15:14
  • 1
    I've tried many solutions (like disable xdebug, activate cache, adding --prefer-dist) none of that works, by chance I've come on this answer, And it was the only solution who really solve the issue. Should be marked as best answer for my case. – Ahmed Kooli Oct 03 '17 at 19:01
0

To diagnose this use I used the require command with -vvv attribute.

composer require larapack/dd -vvv

In my case I've found that the slow speed of composer was because of fxp/composer-asset-plugin.

composer global show
composer global remove fxp/composer-asset-plugin

and voila

Liam Kernighan
  • 2,335
  • 1
  • 21
  • 24