我的项目自动化部署依赖Composer来安装所有依赖项
每次部署时,部署脚本都要求重新安装,但composer.lock始终相同,部署之间没有依赖关系更改。
使用版本号("twig/twig": "1.12.*"
)引用的库从缓存加载。但是具有分支/提交引用("dompdf/dompdf" : "dev-master#424c235"
)的那些总是触发GitHub的git克隆。
至于其他库,这些版本没有更改,但没有从缓存中加载。
Loading composer repositories with package information
Installing dependencies from lock file
- Installing phenx/php-font-lib (0.2.1)
Loading from cache
- Installing dompdf/dompdf (dev-master 424c235)
Cloning 424c235
- Installing endroid/qrcode (dev-master 4eb83c9)
Cloning 4eb83c9
- Installing j4mie/idiorm (v1.3.0)
Loading from cache
- Installing j4mie/paris (v1.3.0)
Loading from cache
- Installing jamesiarmes/php-ews (master edbcb65)
Cloning edbcb65
- Installing symfony/process (v2.3.1)
Loading from cache
- Installing kriswallsmith/assetic (dev-master 0a55a9b)
Cloning 0a55a9b
- Installing kriswallsmith/buzz (v0.10)
Loading from cache
- Installing psr/log (1.0.0)
Loading from cache
- Installing monolog/monolog (1.5.0)
Loading from cache
- Installing mtdowling/cron-expression (v1.0.1)
Loading from cache
- Installing respect/validation (0.4.4)
Loading from cache
- Installing ruudk/twitter-oauth (dev-master a4c0094)
Cloning a4c0094
- Installing slim/slim (2.2.0)
Loading from cache
- Installing slim/extras (2.0.1)
Loading from cache
- Installing symfony/console (v2.2.2)
Loading from cache
- Installing tedivm/jshrink (v0.5.1)
Loading from cache
- Installing twig/twig (v1.12.3)
Loading from cache
- Installing zendframework/zend-stdlib (2.1.5)
Loading from cache
- Installing zendframework/zend-authentication (2.1.5)
Loading from cache
- Installing zendframework/zend-permissions-acl (2.1.5)
Loading from cache
- Installing zendframework/zend-session (2.1.5)
Loading from cache
TL;DR
如何让Composer从本地缓存中提取提交引用的依赖项?
不要从Github克隆,而是下载ZIP。当您更新时,标志--prefer-dist
将触发此操作。如果没有这一点,就没有该包的缓存条目,只有vendor
文件夹中的克隆repo,它会拉入任何更改,然后检查出所需的提交id。