最近想学习一下yii2,但是composer一直安装失败,php -r "readfile('https://getcomposer.org/installer');" | php 执行会出现报错:
Warning: readfile(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify faile
d in Command line code on line 1
Warning: readfile(): Failed to enable crypto in Command line code on line 1
Warning: readfile(https://getcomposer.org/installer): failed to open stream: ope
ration failed in Command line code on line 1
而下载composer-setup.exe进行安装又会出现报错:
Connection Error [ERR_CONNECTION]: Unable to connect to getcomposer.org
Request to https://getcomposer.org/installer failed with errors:
SSL: Handshake timed out. Failed to enable crypto. Failed to open stream: operation failed
非常纠结。。
最终的方案:先在官网下载composer.phar(我也上传分享了一个,下载链接http://download.youkuaiyun.com/detail/st091zsc/9380118)
将composer.phar粘贴到php.exe的同级文件夹下(比如:D:\xampp\php),
新建composer.bat,内容是
@ECHO
OFF
php "%~dp0composer.phar" %*,
然后将php放到环境变量中,具体操作是右键点击“计算机”,选“属性”->“高级系统设置”->“环境变量”,可在用户变量中新建“path”,值为php.exe的路径,
即以上例子中的“D:\xampp\php”。
到此,安装已经完成,再打开cmd,输入“composer
-v”,出现
则已经安装完成。