安装YII2时运行:
php composer.phar global require "fxp/composer-asset-plugin:^1.2.0"
报错could not open input file:composer.phar
重新安装composer时又报错:
C:\Users\Administrator>php -r "readfile(‘https://getcomposer.org/installer‘);" | php
报错如下:
All settings correct for using Composer
Downloading...
Failed to decode zlib stream,问题就这里,
编辑php.ini,搜索zlib,将zlib.output_compression = Off改成zlib.output_compression = On.
编辑完后,重启服务。
再次运行C:\Users\Administrator>php -r "readfile(‘https://getcomposer.org/installer‘);" | php
结果如下:Composer (version 1.4.2) successfully installed to: C:\Users\Administrator\composer.phar
User it:php composer.phar
之后呢,改变composer的镜像为中国国内镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
最后,再次运行
php composer.phar global require "fxp/composer-asset-plugin:^1.2.0"
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing fxp/composer-asset-plugin (v1.3.1): Downloading (100%)
Writing lock file
Generating autoload files
至此,Composer Asset插件:composer-asset-plugin安装成功。
运行composer self-update,再接着安装yii2高级应用程序模板。
不过在进行安装yii2高级应用程序模板的时候发现速度太慢了,别急,按步骤一步步来。
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.12
在安装的过程中会遇见让我输入一个token,这个token由github给我们生成。到github.com上用qq邮箱注册一个账号后,通过邮箱验证然后进入personal settings这个面板点击左侧导航栏最下一个Personal access tokens,token名随便填一个,生成一个token。将这个生成的token保存好,然后在命令行中粘贴这个生成的token,enter继续,会提示Token stored successfully.然后继续安装。
原文地址:http://11797017.blog.51cto.com/11787017/1943673