composer-php - 在 Composer 中,为什么有些依赖项 'Load' 来自缓存,有些依赖项 'clone' 来自缓存

标签 composer-php

我正在尝试优化项目上的 composer 安装 流程。我已经安装了 Prestissimo,将所有开发依赖项移至“require-dev”中,并在 composer.json 文件中将“preferred-install”设置为“dist”。所有这些都将安装时间从约 4 分钟减少到约 2 分钟。

我的依赖项包括 Gitlab 上的一些我自己的私有(private)存储库,当我观看 Composer 安装过程时,我的存储库显示“从缓存克隆”,每个存储库需要几秒钟的时间来处理,而所有其他依赖项都显示“正在加载”从缓存中'并几乎立即处理。

这是composer.json

{
    "name": "my-project",
    "description": "My Project",
    "minimum-stability": "stable",
    "require": {
        "toruinteractive/ti-cms": "0.13.1"
    },
    "require-dev" : {
        "yiisoft/yii2-debug": "^2.0@dev"
    },
    "config": {
        "fxp-asset": {
          "installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
          }
        },
        "process-timeout": 1800,
        "preferred-install" : "dist"
    },
    "extra": {
        "require-bower" : {
            "angular-elastic" : "2.5.*",
            "angular-trix" : "1.0.2",
            "aos":"2.1.1",
            "handlebars" : "4.0.*",
            "bootstrap-toggle" : "^2.2.2",
            "image-map-resizer" : "1.0.*"
        }
    },
    "repositories": [
        { "type": "git", "url" : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7b0bea397b0bea3bbb6b5f9b4b8ba" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-banner.git" },
        { "type": "git", "url" : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cbaca2bf8baca2bfa7aaa9e5a8a4a6" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-blog.git" },
        { "type": "git", "url" : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82e5ebf6c2e5ebf6eee3e0ace1edef" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-suggest.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a0aeb387a0aeb3aba6a5e9a4a8aa" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-cms.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="32555b4672555b465e53501c515d5f" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-dashboard.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="05626c7145626c716964672b666a68" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-file.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="75121c0135121c011914175b161a18" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-image.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="15727c6155727c617974773b767a78" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-export-import.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f1969885b19698859d9093df929e9c" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-login.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="57303e2317303e233b36357934383a" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-navbar.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfb8b6ab9fb8b6abb3bebdf1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-page.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="50373924103739243c31327e333f3d" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-search.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89f918cb89f918c94999ad69b9795" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-slides.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec8b8598ac8b8598808d8ec28f8381" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-superadmin.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d5a54497d5a5449515c5f135e5250" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-translator.git" },
        { "type": "git", "url":  "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="17707e6357707e637b76753974787a" rel="noreferrer noopener nofollow">[email protected]</a>:ti-cms/ti-tree.git" }
    ]
}

这是 composer install 输出...

ghost$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 45 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (2.0.5): Loading from cache
  - Installing bower-asset/jquery (3.2.1): Loading from cache
  - Installing bower-asset/bootstrap (v3.3.7): Loading from cache
  - Installing bower-asset/inputmask (3.3.10): Loading from cache
  - Installing bower-asset/punycode (v1.3.2): Loading from cache
  - Installing bower-asset/yii2-pjax (2.0.7.1): Loading from cache
  - Installing cebe/markdown (1.1.2): Loading from cache
  - Installing ezyang/htmlpurifier (v4.9.3): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing monolog/monolog (1.23.0): Loading from cache
  - Installing paragonie/random_compat (v2.0.11): Loading from cache
  - Installing phenx/php-font-lib (0.4): Loading from cache
  - Installing phenx/php-svg-lib (0.1): Loading from cache
  - Installing phpoffice/phpexcel (1.8.1): Loading from cache
  - Installing yiisoft/yii2 (2.0.13.1): Loading from cache
  - Installing bower-asset/jquery-ui (1.11.4): Loading from cache
  - Installing yiisoft/yii2-jui (2.0.6): Loading from cache
  - Installing yiisoft/yii2-bootstrap (2.0.7): Loading from cache
  - Installing yiisoft/yii2-httpclient (2.0.5): Loading from cache
  - Installing yiisoft/yii2-authclient (2.1.4): Loading from cache
  - Installing toruinteractive/ti-tree (0.13.1): Cloning 867ff3625c from cache
  - Installing toruinteractive/ti-translator (0.13.1): Cloning eec41060e4 from cache
  - Installing toruinteractive/ti-superadmin (0.13.1): Cloning a783cd0bb9 from cache
  - Installing toruinteractive/ti-suggest (0.13.1): Cloning b52895d1ab from cache
  - Installing toruinteractive/ti-slides (0.13.1): Cloning e0a5f9738f from cache
  - Installing toruinteractive/ti-search (0.13.1): Cloning a2e1f8ac89 from cache
  - Installing toruinteractive/ti-page (0.13.1): Cloning 9b3653a648 from cache
  - Installing toruinteractive/ti-navbar (0.13.1): Cloning 711fe81e0a from cache
  - Installing toruinteractive/ti-login (0.13.1): Cloning e7f64c010b from cache
  - Installing imagine/imagine (v0.6.3): Loading from cache
  - Installing flowjs/flow-php-server (v1.0.3): Loading from cache
  - Installing toruinteractive/ti-image (0.13.1): Cloning 5089e00de0 from cache
  - Installing toruinteractive/ti-file (0.13.1): Cloning 68ec65c025 from cache
  - Installing arogachev/yii2-excel (0.1.1): Loading from cache
  - Installing toruinteractive/ti-export-import (0.13.1): Cloning cd8309c01d from cache
  - Installing toruinteractive/ti-dashboard (0.13.1): Cloning ccb9d159e4 from cache
  - Installing toruinteractive/ti-blog (0.13.1): Cloning e0d3296d01 from cache
  - Installing toruinteractive/ti-banner (0.13.1): Cloning cadf895998 from cache
  - Installing sentry/sentry (0.17.0): Loading from cache
  - Installing ramsey/uuid (3.7.1): Loading from cache
  - Installing mandrill/mandrill (1.0.55): Loading from cache
  - Installing fightbulc/moment (1.26.10): Loading from cache
  - Installing dompdf/dompdf (v0.7.0): Loading from cache
  - Installing toruinteractive/ti-cms (0.13.1): Cloning 6fd9d9fe53 from cache
  - Installing yiisoft/yii2-debug (dev-master b2cd366): Loading from cache
Generating autoload files

所以我的问题是如何让我自己的包从缓存中“加载”以加快安装过程?

最佳答案

我认为这只是 git repos 和准备好的包之间的区别,即克隆 git repo 与 dist(zip/tar) 文件。一旦缓存了 zip 文件,只需解压缩即可。

对于 git 存储库,克隆是一项需要更多时间的操作,可能会通过网络来确保缓存的存储库仍然是最新的,然后将实际的缓存存储库克隆到工作目录。

如果您希望从缓存加载自己的包,请尝试以 dist (zip/tar) 格式分发它们。

关于composer-php - 在 Composer 中,为什么有些依赖项 'Load' 来自缓存,有些依赖项 'clone' 来自缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47330302/

相关文章:

symfony - 在 symfony 3.4 上安装 FOSUserBundle 时出错

composer-php - 无法初始化中央 HHBC 存储库 : Failed to initialize schema

php - ZF2 - 运行时异常 : Module (ZfcUserDoctrineORM) could not be initialized

bash - 如何在composer之前使用各自的php版本名称

php - 全局安装 Composer 以供 laravel 使用?

php - 如何在 MAMP 的 php 版本上运行 composer?

linux - bash:/usr/local/bin/composer.phar 没有这种类型的文件或文件夹(ubuntu 16.04)

php - 有没有办法用 Composer 卸载开发依赖项?

php - 使用 composer create-project 安装特定的 laravel 5 版本

php - 如何使用 Composer 安装 jQuery?