通过 Composer 安装 Yii 2.0

一、在 Windows 中,你需要下载并运行 Composer-Setup.exe

二、安装composer后,更新镜像为国内镜像

C:\Users\Administrator>d:

D:\>cd wamp

D:\wamp>cd www

D:\wamp\www>composer config -g repo.packagist composer https://packagist.phpcomp
oser.com(更新镜像为国内)
You are running composer with xdebug enabled. This has a major impact on runtime
performance. See https://getcomposer.org/xdebug(提示php.ini中xdebug需关闭)

三、更新composer为最新版本

D:\wamp\www>composer self-update(更新为最新)
You are already using composer version 1.1.0 (stable channel).

四、开始安装yii

D:\wamp\www>composer global require “fxp/composer-asset-plugin:~1.1.0”
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
– Installing fxp/composer-asset-plugin (v1.1.4)
Downloading: 100%

Writing lock file
Generating autoload files

五、创建项目

D:\wamp\www>composer create-project –prefer-dist yiisoft/yii2-app-basic basic
Installing yiisoft/yii2-app-basic (2.0.8)
– Installing yiisoft/yii2-app-basic (2.0.8)
Downloading: 100%

Created project in basic
Loading composer repositories with package information
Updating dependencies (including require-dev)
Reading bower.json of bower-asset/jquery (2.1.0)
Could not fetch https://api.github.com/repos/jquery/jquery-dist/contents/bower.j
son?ref=9434e03193c45d51bbd063a0edd1a07a6178d33f, please create a GitHub OAuth t
oken to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+
on+7RBSGPCTR5ZQFHB+2016-05-13+0824
to retrieve a token. It will be stored in “C:/Users/Administrator/AppData/Roamin
g/Composer/auth.json” for future use by Composer.
Token (hidden):
Token stored successfully.
– Installing yiisoft/yii2-composer (2.0.4)
Downloading: 100%

– Installing swiftmailer/swiftmailer (v5.4.2)
Downloading: 100%

– Installing bower-asset/jquery (2.2.3)
Downloading: 100%

– Installing bower-asset/yii2-pjax (v2.0.6)
Downloading: 100%

– Installing bower-asset/punycode (v1.3.2)
Downloading: 100%

– Installing bower-asset/jquery.inputmask (3.2.7)
Downloading: 100%

– Installing cebe/markdown (1.1.0)
Downloading: 100%

– Installing ezyang/htmlpurifier (v4.7.0)
Downloading: 100%

– Installing yiisoft/yii2 (2.0.8)
Downloading: 100%

– Installing yiisoft/yii2-swiftmailer (2.0.5)
Downloading: 100%

– Installing yiisoft/yii2-codeception (2.0.5)
Downloading: 100%

– Installing bower-asset/bootstrap (v3.3.5)
Downloading: 100%

– Installing yiisoft/yii2-bootstrap (2.0.6)
Downloading: 100%

– Installing yiisoft/yii2-debug (2.0.6)
Downloading: 100%

– Installing bower-asset/typeahead.js (v0.11.1)
Downloading: 100%

– Installing phpspec/php-diff (v1.1.0)
Downloading: 100%

– Installing yiisoft/yii2-gii (2.0.5)
Downloading: 100%

– Installing fzaninotto/faker (v1.6.0)
Downloading: 100%

– Installing yiisoft/yii2-faker (2.0.3)
Downloading: 100%

Writing lock file
Generating autoload files
> yii\composer\Installer::postCreateProject
chmod(‘runtime’, 0777)…done.
chmod(‘web/assets’, 0777)…done.
chmod(‘yii’, 0755)…done.

D:\wamp\www>

发表评论

电子邮件地址不会被公开。 必填项已用*标注