Yii2 安装 [ 2.0 版本 ]
这些天看了一下,发现还有很多人对 Yii2 安装存在许多问题,在网上搜了很多资料,才发现他们都很不全面,以至于走了很多弯路,
下面我把完整的安装流程介绍给大家:按照这个流程走,相信你一定可以成功!
总感觉这个教程排版都很靠左,感觉这个样式排版不好的话,可以去我的博客看:http://happymc.iteye.com/blog/2150829
希望对你们有帮助!
前提:非常重要,你的php版本必须是php5.4以上
1.首先需要下载应用模板,分为基础模板和高级应用模板,这里我以高级应用模板为例子 :
去这里现在高级应用模板 https://github.com/yiisoft/yii2-app-advanced
2.下载完之后解压放在www目录我是放在 D:\wamp\www\yii2\advanced
cmd dos命令进入这个D:\wamp\www\yii2\advanced下:
3.运行 php -r "readfile('https://getcomposer.org/installer');" | php
4.这是就在D:\wamp\www\yii2\advanced
目录下面下载了一个composer.phar
文件,有了这个文件就可以执行php composer.phar
命令了,提示:
5.准备所有插件!!非常重要,少了这步一切都会失败 (记得配置php环境变量啊)
执行命令:php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
6.安装我们的yii2的应用:
执行命令:php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced ../yii2test
就会在上一层目录下生成yii2test应用 。
请注意,到第六步很可能就一直停在那里了,这个时候,登录GitHub的用户名和密码没有就注册个账号,退出cmd,重新执行第6步可。
若提示安装过程中输入你的 GitHub 的用户名和密码。那就输入它们并继续即可。现在可能是输入token了
7.最后一步:初始化我们的应用,初始化是在你创建的yii2test目录下 执行cmd init命令 选0 y
ok,这么我们的yii2的安装就完成了,进入测试目录:
localhost/yii2/yii2test/frontend/web/index.php
会看到如下界面:
这就表明的你的yii2安装成功了,一定要记住你的php版本是php5.4以上的!
小马哥
最后登录:2016-09-25
在线时长:40小时54分
- 粉丝66
- 金钱615
- 威望60
- 积分1615
共 68 条评论
66666 写的不错 安装一步到位
安装到第5步就出错呢,环境变量也配置了,报错怎么回事呢,求解决
Changed current directory to C:/Users/Admingistrator/AppDate/Roaming/Composer
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks<> in C:\Users\Administrator\AppData\Roaming\Composer\Vendor\fxp\composer-asset-plugin\Repository\VcsPackageFilter.php on line 272
这个问题你解决没有,我也遇到了。。
我在https://github.com/bubifengyun/book-yii2-dev-process,准备借助yiichina里的教程,编辑成一本书,最后用某高校LaTeX论文模板美化一下,每月或者更长时间发布PDF教程总结,求支持。
我想把你的教程录入到这本书里,并记录您的名字及原网址,可否?谢谢啦。
非常支持
@小马哥 https://github.com/bubifengyun/book-yii2-dev-process/blob/master/src/ch-02.md
非常感谢,现在把你的教程给弄过来啦,请指示。
楼主,在我进行完第四步之后会报这样的错,是为什么呢??
D:\wampserver\wamp\wamp\www\yii2\advanced>php composer.phar global require "fxp/
composer-asset-plugin:1.0.0"
Changed current directory to C:/Users/yyf/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Loading from cache
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\V
ersionParser::parseLinks() in C:\Users\yyf\AppData\Roaming\Composer\vendor\fxp\c
omposer-asset-plugin\Repository\VcsPackageFilter.php on line 272
Call Stack:
0.0130 404864 1. {main}() D:\wampserver\wamp\wamp\www\yii2\advanced\co
mposer.phar:0
0.0130 407800 2. require('phar://D:/wampserver/wamp/wamp/www/yii2/adva
nced/composer.phar/bin/composer') D:\wampserver\wamp\wamp\www\yii2\advanced\comp
oser.phar:25
0.1100 4404216 3. Composer\Console\Application->run() phar://D:/wampser
ver/wamp/wamp/www/yii2/advanced/composer.phar/bin/composer:43
0.1190 4814128 4. Symfony\Component\Console\Application->run() phar://D
:/wampserver/wamp/wamp/www/yii2/advanced/composer.phar/src/Composer/Console/Appl
ication.php:82
应该输入composer global require "fxp/composer-asset-plugin:~1.0.3"就好了
好文章,顶一个
提示php不是内部命令。。环境变量里添加了。php.ini文件里也开启 extension_dir ,为什么
第六步到这里就一直不动了,
Reading bower.json of bower-asset/sizzle(1.10.9)
我已经登陆github,这是什么原因啊?
兄弟,你的这个问题解决了吗?
(第六步到这里就一直不动了,
Reading bower.json of bower-asset/sizzle(1.10.9))
找不到原因啊!求解
完成之后访问出现这个问题:Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: E:\www\yii2\yii2test1/vendor\bower/jquery/dist
我把这个目录E:\www\yii2\yii2test\vendor\bower\bower-asset下的 jquery/dist拷过来才好了,这是什么原因啊?为什么多一个bower-asset的目录
按照这个步骤装完后,报错了。。:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: D:\wamp\www\yii_advanced/vendor\bower/jquery/dist
D:\wamp64\www\yii2>php -r "readfile('https://getcomposer.org/installer');" | php 'php' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
为什么我的电脑执行不了这样的命令呢?
我觉得这个应该标明是windows下的yii2安装,我在linux下用这个装了好久,不成,后来就用http://www.yiichina.com/download里说的,很快就装成了。
出了这个错,好蛋疼,求解~
F:\wamp\www\YII2\advanced>php composer.phar global require "fxp/composer-asset-p
lugin:1.0.0"
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
You are running composer with xdebug enabled. This has a major impact on runtime
performance. See https://getcomposer.org/xdebug
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Loading from cache
The "fxp/composer-asset-plugin" plugin requires composer-plugin-api 1.0.0, this
WILL break in the future and it should be fixed ASAP (require ^1.0 for example
).
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\V
ersionParser::parseLinks() in C:\Users\Administrator\AppData\Roaming\Composer\ve
ndor\fxp\composer-asset-plugin\Repository\VcsPackageFilter.php on line 272
Call Stack:
0.2098 416848 1. {main}() F:\wamp\www\YII2\advanced\composer.phar:0 0.2254 419704 2. require('phar://F:/wamp/www/YII2/advanced/composer.ph
ar/bin/composer') F:\wamp\www\YII2\advanced\composer.phar:24
0.3970 4968904 3. Composer\Console\Application->run() phar://F:/wamp/ww
w/YII2/advanced/composer.phar/bin/composer:43
0.4282 5416184 4. Symfony\Component\Console\Application->run() phar://F
:/wamp/www/YII2/advanced/composer.phar/src/Composer/Console/Application.php:99
0.4282 5575648 5. Composer\Console\Application->doRun() phar://F:/wamp/
这问题咋办呀,求解~
楼主,第六部出现
Problem 1
- yiisoft/yii2 2.0.x-dev requires bower-asset/jquery.inputmask ~3.2.2 -> no
matching package found.
- yiisoft/yii2 dev-master requires bower-asset/jquery.inputmask ~3.2.2 -> no
matching package found.
- yiisoft/yii2 2.0.8 requires bower-asset/jquery 2.2.*@stable | 2.1.*@stable
| 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.7 requires bower-asset/jquery 2.2.*@stable | 2.1.*@stable
| 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stabl
e -> no matching package found.
- Installation request for yiisoft/yii2 >=2.0.6 -> satisfiable by yiisoft/yi
i2[2.0.6, 2.0.7, 2.0.8, dev-master, 2.0.x-dev].
Potential causes:
imum-stability setting
see https://getcomposer.org/doc/04-schema.md#minimum-stability for more det
ails.
Read https://getcomposer.org/doc/articles/troubleshooting.md for further commo
n problems.
请问这个是什么问题呢?求解。
第五步的时候出错了
C:\wamp\www\yii2\advanced>php composer.phar global require "fxp/composer-asset-plugin:1.0.0" Changed current directory to C:/Users/Floruit/AppData/Roaming/Composer You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for fxp/composer-asset-plugin 1.0.0 -> satisfiable by fxp/composer-asset-plugin[v1.0.0]. - fxp/composer-asset-plugin v1.0.0 requires composer-plugin-api 1.0.0 -> no matching package found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details. Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. Installation failed, deleting ./composer.json. C:\wamp\www\yii2\advanced>
composer global require "fxp/composer-asset-plugin:~1.1.1"
找不到 1.0.0 的包,改成 1.1.1 好了为什么我按照上面的步骤操作后,项目文件夹下没有:vendor 这个文件夹和这个文件夹下的相关文件?
你指的composer global require "fxp/composer-asset-plugin:~1.1.1" ,只操作了这一步?
在第一步不是已经下载了高级版的包了么,为什么在后面的步骤里面又要从github下载包呢?? 没看懂,求大神指点下
同感,希望有大神出来指点下.
composer global require fxp/composer-asset-plugin --no-plugins
过来看看的啊
第五步出错如何处理呢