Home  >  Article  >  php教程  >  从零开始学YII2框架(二)通过 Composer 安装扩展插件,yii2composer

从零开始学YII2框架(二)通过 Composer 安装扩展插件,yii2composer

WBOY
WBOYOriginal
2016-06-13 09:26:50925browse

从零开始学YII2框架(二)通过 Composer 安装扩展插件,yii2composer

目前yii2的扩展还不是很多,截止到今天,在官网一共有33个,不过这些插件中不乏有优秀的扩展插件,

我尝试了几个,发现了一系列好用的Yii2插件,作者是来自印度的krajee团队,他们写的插件都很好用。推荐一下。

krajee团队的网站:http://krajee.com,有几个不错的插件可以尝试。

下面来介绍Yii2的插件安装方法。通过Composer安装插件yii2-detail-view。

Git

推荐安装Git,Composer安装插件时候会用到Git Clone,Git官方下载网站:传送门

如果你没有安装过Git,CMD执行命令时会提示你git不是有效的命令。然后去找硬盘下载地址。实际上不安装git也没影响。

Windows下安装完Git,配置下环境变量,把;D:\Program Files\Git\bin加入Path环境变量中。

安装方法

yii2-detail-view

官方说明:

Installation 
The preferred way to install this extension is through composer.
Either run:
$ php composer.phar require kartik-v/yii2-detail-view "*"
or add:
"kartik-v/yii2-detail-view": "*"
to the require section of your composer.json file.

这是相对于Linux环境下安装的方法,Windows下使用Composer

CMD下执行命令:composer require kartik-v/yii2-detail-view "*"


安装完毕,我们会看到安装过程中,安装了5个其他的插件,这些都是和yii2-detail-view有依赖关系的插件,

这就是Composer工具的好用之处,自动分析依赖关系,帮助我们完美安装。

在webroot/appname/vendor目录下看见"kartik-v"目录。看到路径下存放着6个目录。说明安装成功。

插件安装就到这里,至于如何使用。后面学习过程中再介绍。^_^

yii2在使用composer安装时出现如下错误,大侠帮忙,……

你php没有开启mongodb扩展~~~~和Composer没关系吧

打开你的php.ini 开启mongodb extension (把前面的“;”号去掉)

重启你的服务器(apache、iis...)

然后重试一下

如果是linux系统的,我也不清楚,你搜索下吧
 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn