phpcomposer 镜像使用

composer config -g repo.packagist composer

case1 NoSslException

The openssl extension is required for SSL/TLS protection but is not availab
le. If you can not enable the openssl extension, you can disable this error
, at your own risk, by setting the 'disable-tls' option to true.

php 的 php_openssl.dll 模块有关,默认 php.ini 是没有开这个模块的。


php -i | grep php.ini    // 找到 php.ini 文件位置
vi php.ini  去掉 extension=php_openssl.dll 前面的 ; 把模块打开
reload php

case2 有版本要求,但可以忽略

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1

- Installation request for twig/twig v2.6.0 -> satisfiable by twig/twig[v2.6.0].
- twig/twig v2.6.0 requires php ^7.0 -> your PHP version (5.5.22) does not satisfy that requirement.

这个案例的原因是,包依赖的 php 版本要求大于 7,前提:当你确定就算环境版本不符合也要安装 vendor,可以选择忽略版本限制。


composer install --help | grep ignore    // 可以看到有一个忽略版本的参数
composer install --ignore-platform-reqs