69

我正在使用 composer ( http://getcomposer.org/ ) 来管理Symfony2(symfony v 2.1.3) 中已安装的包。作曲家的版本是de3188c.

我有一个问题,当我将新包添加到 composer.json 并执行它时,显示有关更新依赖项的消息的时间非常少。

我在 composer.json 中有这些数据(见下文),执行时间大约是 20 分钟!!!互联网连接速度足够快,我可以非常快地下载大文件......

有什么技巧可以让它更快吗?

{
"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"
}
4

5 回答 5

80

尝试为 composer.json 中的每个依赖项指定一个版本,并--prefer-dist在调用 composer.json 时使用该选项。它将从存储库(如果可用)而不是单个文件下载 ZIP 文件。

php composer.phar install --prefer-dist
于 2012-11-16T09:37:06.407 回答
23

既然你接受了一个答案,看起来这解决了你的问题。以防万一其他人偶然发现这个问题(就像我在搜索时所做的那样),就我而言,一个非常慢的 Composer 安装与我的 PHP 版本有关(警告,我是一个完整的 Composer 新手) ,尽管 Composer 通过了标准检查并表示一切正常。我运行 Ubuntu 12.04 LTS,并且懒得从 Precise 存储库中的默认 PHP 5.3.10(您正在运行的相同版本)升级。

通过 Composer 安装 Twig 最初花了我大约 30 分钟。在花了一个多小时后,我放弃了安装 Doctrine。我升级到 5.4.17(使用这个 PPA https://launchpad.net/~ondrej/+archive/php5)并且安装 Doctrine 在几秒钟内完成。

于 2013-07-25T00:32:42.987 回答
15

我发现它也很慢,在几十分钟内慢。

对我来说,我添加-vvv并发现它挂在类似的东西上 Downloading https://packagist.org/p/provider-active$53cdf887c8d2925b3501f47d6980fb7bda2310716369bf7a84857c6e62bbab0f.json

然后我转到浏览器并尝试下载该 JSON 文件,果然如此。缓慢的原因是 packagist.org。

于 2014-08-05T22:57:35.427 回答
14

就我而言,上述建议没有任何作用。所做的是将HTTPS协议用于packagist

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

或者

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

取决于您的设置

于 2015-07-07T01:43:15.923 回答
0

为了诊断这种用法,我使用了带有-vvv属性的require命令。

composer require larapack/dd -vvv

就我而言,我发现 composer 速度慢是因为 fxp/composer-asset-plugin。

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

于 2018-03-08T08:57:07.927 回答