排行榜

composer安装Yii2

本文阅读 2 分钟
首页 后端开发 正文
广告

composer安装的确是个大问题,我在初次安装Yii2时使用composer从未成功过,几乎放弃,后来在一个朋友的帮助下,终于是把composer安装给整通了,国内composer方式直接安装Yii2最大的一个问题就是强,使用Composer中国全量镜像(http://www.phpcomposer.com/)不用翻.强就可以成功安装Yii2,这是关键,我给新手说一说这个是怎么做的:

//全局安装composer(windows)

将composer.phar放置到php.exe同一目录下,再编辑一个composer.bat文件,这样就可以直接使用composer安装了,而无需再输入php composer.phar,这样的长格式命令。

注意:应将php.exe的运行目录事先加入到系统的path环境变量当中去!

//文件及存放目录D:\php\php.exe
D:\php\composer.phar
//设置path(追加)
;D:\php
//创建composer.bat文件D:\php>echo @php "%~dp0comoser.phar" %*>composer.bat
//查看composer.bat文件是否已成功创建,能看到后面一行的内容则说明OKD:\php>type composer.bat
@php "%~dp0comoser.phar" %*


//测试一下composer是否可以随处运行了:

d:\php>cd \www
d:\www>composer -V
Composer version 1.0.2 2016-04-21 12:30:18//出现上面的composer版本信息说明composer全局安装已经顺利完成!
//Composer中国全量镜像http://www.phpcomposer.com/
//将Composer更新站点替换为中国全量镜像(很重要,此步没做以后的都不会成功)D:\php>composer config -g repo.packagist composer https://packagist.phpcomposer.com

//到此为止,你就可以使用composer进行Yii2的安装了

//安装fxp/composer-asset-plugin,如果版本不对则会报一堆的错误

d:\www>composer global require "fxp/composer-asset-plugin:~1.1.1"

Changed current directory to C:/Users/User/AppData/Roaming/Composer
./composer.json has been updated
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
//安装Ysii2,所有的部件都是Downloading: 100%,最后才会显示安装成功,如果卡在Downloading说明“中国全量镜像”未设置成功。
d:\www>composer create-project --prefer-dist yiisoft/yii2-app-basic basic
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing yiisoft/yii2-composer (2.0.4)
Downloading: 100%
- Installing bower-asset/jquery (2.2.3)
Downloading: 100%
- Installing bower-asset/yii2-pjax (v2.0.6)
Downloading: 100%
- Installing letyii/yii2-rbac-mongodb (dev-master 1f17c4e)
Cloning 1f17c4ea8e5de189a5c8df668de01e3130995e3e
- Installing swiftmailer/swiftmailer (v5.4.1)
Downloading: 100%
- Installing yiisoft/yii2-swiftmailer (2.0.5)
Downloading: 100%
- Installing yiisoft/yii2-mongodb (2.0.4)
Downloading: 100%
- Installing mdmsoft/yii2-admin (2.6)
Downloading: 100%
- Installing imagine/imagine (v0.5.0)
Downloading: 100%
- Installing yiisoft/yii2-imagine (2.0.3)
Downloading: 100%
- Installing raoul2000/yii2-workflow (1.0.0)
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.5.0)
Downloading: 100%
- Installing yiisoft/yii2-faker (2.0.3)
Downloading: 100%
Writing lock file
Generating autoload files

d:\www>

OK!看看你的Yii2是否已经安装成功!

还有一些composer常用的命令,你可以了解一下:

//composer更新composer.phar
d:\www>composer selfupdate
You are already using composer version 1.0.2 (stable channel).
//更新缓存
d:\www>composer clear-cache
Clearing cache (cache-dir): C:\Users\User\AppData\Local\Composer
Clearing cache (cache-files-dir): C:\Users\User\AppData\Local\Composer\files
Clearing cache (cache-repo-dir): C:\Users\User\AppData\Local\Composer\repo
Cache directory does not exist (cache-vcs-dir):
All caches cleared.
d:\www>

祝你成功!


本文来自投稿,不代表本站立场,如若转载,请注明出处:https://www.unfit.cn/archives/42.html
js利用form+iframe解决跨域post和get提交
« 上一篇 07-19
Yii动态AR模型
下一篇 » 07-19
广告

相关推荐