Composer 是 PHP5以上 的一个依赖管理工具。它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们。Composer 不是一个包管理器。是的,它涉及 "packages" 和 "libraries",但它在每个项目的基础上进行管理,在你项目的某个目录中(例如 vendor)进行安装。默认情况下它不会在全局安装任何东西。因此,这仅仅是一个依赖管理。
安装好Composer时通过composer install,发现没有正常安装,而是提示:
[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. 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.
解决方法一(未测试):
composer config -g -- disable-tls true
然而出现了另外的问题:
[Composer\Downloader\TransportException]
Your configuration does not allow connections to http://packagist.org/packages.json. See https://getcomposer.org/doc/06-config.md#secure-http for details.
所以需要再次进行设置,禁用SSL
-
composer config secure-http false
-
composer config -g secure-http false
之后,一部分可以正常安装了,还有一部分提示超过300stimeout,所以对时间进行设置:
增加COMPOSER_PROCESS_TIMEOUT,通过命令composer config --list
看到默认是300s,然后通过命令composer config -g process-timeout 600
增加COMPOSER_PROCESS_TIMEOUT至600s。
至此,Composer能够正常运行。
方法二:
编辑php.ini文件,首先,定位到:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "./"
; On windows:
extension_dir = "ext"
删除extension_dir = "./"
和extension_dir = "ext"
前面的分号,取消注释这两行代码,配置PHP插件目录为./ext
。
然后,定位到:
...
;extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
...
删除extension=php_openssl.dll
前面的分号,取消注释,从而启用OpenSSL插件。
注意:因为SSL连接需要认证,所以继续下面的步骤之前,需要准备好CA证书(建议把证书保存到C:\php-5.6.24\verify
目录中),可以从https://curl.haxx.se/docs/caextract.html处下载。
接下来,定位到
;openssl.cafile=
和上面一样,删去分号,取消注释,设置CA证书为openssl.cafile= C:\php-5.6.24\verify\cacert.pem
注 :PHP5.x的ini文件配置ca证书的文件是curl下面
curl.cainfo = C:/Users/liuxian/CA/cacert.pem