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 条评论
写的挺好,但是第一步的下载让我感觉比较懵逼,难道不应该直接下载composer然后开始安装吗?
1.首先需要下载应用模板,分为基础模板和高级应用模板,这里我以高级应用模板为例子 :
去这里现在高级应用模板 https://github.com/yiisoft/yii2-app-advanced
收藏。。。
![F846V6D2UL1SN$$B0I9]T0J.png](/uploads/images/201711/07180015884.png "F846V6D2UL1SN$$B0I9]T0J.png")
请问这是什么问题????急
第五步
D:\wamp64\www\yii2\advanced>php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta3"
Changed current directory to C:/Users/boyu/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
环境变量配的是什么啊
第五步 就一直Updating dependencies (including require-dev)
百度了下说是要弄个镜像,不然连不上国外的链接 这个咋整
好人一生平安!
我就想问你们下载的有Vendor目录么
厉害了,我的哥
第五步出错如何处理呢
过来看看的啊
composer global require fxp/composer-asset-plugin --no-plugins
在第一步不是已经下载了高级版的包了么,为什么在后面的步骤里面又要从github下载包呢?? 没看懂,求大神指点下
同感,希望有大神出来指点下.
为什么我按照上面的步骤操作后,项目文件夹下没有:vendor 这个文件夹和这个文件夹下的相关文件?
你指的composer global require "fxp/composer-asset-plugin:~1.1.1" ,只操作了这一步?
第五步的时候出错了
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 好了楼主,第六部出现
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.
请问这个是什么问题呢?求解。
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/
这问题咋办呀,求解~
出了这个错,好蛋疼,求解~
我觉得这个应该标明是windows下的yii2安装,我在linux下用这个装了好久,不成,后来就用http://www.yiichina.com/download里说的,很快就装成了。
D:\wamp64\www\yii2>php -r "readfile('https://getcomposer.org/installer');" | php 'php' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
为什么我的电脑执行不了这样的命令呢?
按照这个步骤装完后,报错了。。:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: D:\wamp\www\yii_advanced/vendor\bower/jquery/dist