欢迎各位兄弟 发布技术文章
这里的技术是共享的
标签(空格分隔): composer
--prefer-dist 会从github 上下载.zip压缩包,并缓存到本地。下次再安装就会从本地加载,大大加速安装速度。但她没有保留 .git文件夹,没有版本信息。适合基于这个package进行开发。
--prefer-source 会从github 上clone 源代码,不会在本地缓存。但她保留了.git文件夹,从而可以实现版本控制。适合用于修改源代码。
接下来我们进行验证。
[ahcj@localhost test]$ mkdir composer-test
[ahcj@localhost test]$ cd composer-test/
[ahcj@localhost composer-test]$ composer init --require="twig/twig:1.*" -n --profile
[6.1MB/0.00s] Memory usage: 6.07MB (peak: 6.17MB), time: 0s
[ahcj@localhost ~]$ /usr/bin/composer config --list
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https?://packagist.org
[repositories.packagist.org.allow_ssl_downgrade] true
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (/home/ahcj/vendor)
[bin-dir] {$vendor-dir}/bin (/home/ahcj/vendor/bin)
[cache-dir] /home/ahcj/.cache/composer
[data-dir] /home/ahcj/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/home/ahcj/.cache/composer/files)
....省略....
[ahcj@localhost coposertest]$ ll /home/ahcj/.cache/composer/files/twig
ls: 无法访问/home/ahcj/.cache/composer/files/twig: 没有那个文件或目录
[ahcj@localhost composer-test]$ composer install --profile --prefer-source
[6.1MB/0.00s] Loading composer repositories with package information
[6.4MB/6.08s] Updating dependencies (including require-dev)
[102.7MB/18.84s] Package operations: 1 install, 0 updates, 0 removals
[102.7MB/18.84s] - Installing twig/twig (v1.34.4): [102.8MB/20.76s] Cloning f878bab48e from cache
[101.3MB/31.26s] Writing lock file
[101.3MB/31.26s] Generating autoload files
[101.3MB/31.26s] Memory usage: 101.31MB (peak: 109.88MB), time: 31.26s
[ahcj@localhost composer-test]$ rm -rf vendor
[ahcj@localhost composer-test]$ composer install --profile --prefer-source
[6.2MB/0.01s] Loading composer repositories with package information
[6.3MB/0.01s] Installing dependencies (including require-dev) from lock file
[6.8MB/0.02s] Package operations: 1 install, 0 updates, 0 removals
[6.8MB/0.02s] - Installing twig/twig (v1.34.4): [6.9MB/12.90s] Cloning f878bab48e from cache
[6.8MB/33.64s] Generating autoload files
[6.8MB/33.64s] Memory usage: 6.82MB (peak: 6.98MB), time: 33.64s
[ahcj@localhost composer-test]$ ll /home/ahcj/.cache/composer/files/twig
ls: 无法访问/home/ahcj/.cache/composer/files/twig: 没有那个文件或目录
[ahcj@localhost composer-test]$ find -name .git
./vendor/twig/twig/.git
[ahcj@localhost composer-test]$ cd ./vendor/twig/twig/
[ahcj@localhost twig]$ git log | less
....好多,通通省略....
[ahcj@localhost composer-test]$ rm -rf vendor
[ahcj@localhost composer-test]$ composer install --profile --prefer-dist
[6.2MB/0.00s] Loading composer repositories with package information
[6.3MB/0.01s] Installing dependencies (including require-dev) from lock file
[6.8MB/0.01s] Package operations: 1 install, 0 updates, 0 removals
[6.8MB/0.01s] - Installing twig/twig (v1.34.4): [7.0MB/0.01s] D[7.0MB/12.99s] Downloading (0%)[7.0MB/12.99s] [7.0MB/14.48s] Downloading (5%[7.0MB/15.35s] Downloading (10[7.1MB/16.00s] Downloading (15[7.1MB/16.44s] Downloading (20%)[7.[7.1MB/16.86s] Downloading (25[7.1MB/17.08s] Downloading (30[7.2MB/17.50s] Downloading (35[7.2MB/17.71s] Downloading (40%)[7.[7.2MB/17.73s] Downloading (45[7.3MB/17.95s] Downloading (50[7.3MB/18.14s] Downloading (55[7.3MB/18.17s] Downloading (60%)[7.[7.3MB/18.36s] Downloading (65[7.4MB/18.38s] Downloading (70[7.4MB/18.57s] Downloading (75[7.4MB/18.59s] Downloading (80%)[7.[7.5MB/18.61s] Downloading (85[7.5MB/18.80s] Downloading (90[7.5MB/18.82s] Downloading (95[7.5MB/18.86s] Downloading (100%)[7.0MB/18.86s]
[6.8MB/20.34s] Generating autoload files
[6.8MB/20.34s] Memory usage: 6.84MB (peak: 8.12MB), time: 20.34s
[ahcj@localhost composer-test]$ ll /home/ahcj/.cache/composer/files/twig
ls: 无法访问/home/ahcj/.cache/composer/files/twig: 没有那个文件或目录
[ahcj@localhost composer-test]$ ll /home/ahcj/.cache/composer/files/twig
总用量 0
drwxrwxr-x 2 ahcj ahcj 58 8月 18 12:16 twig
[ahcj@localhost composer-test]$ rm -rf vendor
[ahcj@localhost composer-test]$ composer install --profile --prefer-dist
[6.3MB/0.01s] Loading composer repositories with package information
[6.4MB/0.01s] Installing dependencies (including require-dev) from lock file
[6.9MB/0.01s] Package operations: 1 install, 0 updates, 0 removals
[6.9MB/0.02s] - Installing twig/twig (v1.34.4): [7.0MB/0.02s] Loading from cache[7.0MB/0.02s]
[6.9MB/6.43s] Generating autoload files
[6.9MB/6.43s] Memory usage: 6.87MB (peak: 7.13MB), time: 6.43s
[ahcj@localhost composer-test]$ find -name .git
来自 https://www.jianshu.com/p/30e475683629