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 条评论
第五步 woaipai是嘛意思呢 公子
终于安装好了!!不容易啊
楼主没有提到第六步的时候 需要github复制链接生成token,因为要求输入token,我走了很多弯路,果断给差评!!!
呵呵,以前是不需要输入token的,更新的太快,没办法 啊
token怎么获取啊 求告知 !!!
@promise 登录 github
@小马哥 已经装好了,谢谢了!!!
看完这个之后最大的感触就是composer是他们谁搞出来的,这么一大堆问题。而YII2的大神也够大胆的,这么一个问题多多的玩意也要傍。真是个痛苦的世界。
运行第六步安装yii,输入token并保存成功后,提示
Reading bower.json of bower-asset/jquery (2.1.0)
之后一直卡着不往下走了,请问是什么情况?
因为一直卡着不动,终止程序后,直接运行了第七歩初始化成功了,但访问测试页面时出现:
Warning: require(D:\wampserver\wamp\www\yii2test\frontend\web/../../vendor/autoload.php): failed to open stream: No such file or directory in D:\wampserver\wamp\www\yii2test\frontend\web\index.php on line 5 Fatal error: require(): Failed opening required 'D:\wampserver\wamp\www\yii2test\frontend\web/../../vendor/autoload.php' (include_path='.;C:\php\pear') in D:\wampserver\wamp\www\yii2test\frontend\web\index.php on line 5
应该就是因为第六步没安装完成。于是重新运行了第六步创建yii2test2,但还是卡在
Reading bower.json of bower-asset/jquery (2.1.0)
处,请问有解决方案么?
GitHub账号输入了,没输入的话 ,你在安装的时候 ,先登录GitHub,在安装
@小马哥 再哪里输入账号呀?没看到提示。。。
denghp@denghp:~/soft/yii2-app-advanced$ composer global require "fxp/composer-asset-plugin:1.0.0" Changed current directory to /home/denghp/.composer ./composer.json has been created Loading composer repositories with package information [ErrorException] Invalid argument supplied for foreach() require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [packages1] ... [packagesN]
为啥直接报这个错误呢?
还真不太清楚呢,按照这个教程按安装,为啥你们报的错各种各样呢
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Failed to enable crypto failed to open stream: operation failed
出现这个错误知道是什么原因吗?我openssl.dll已开启
这个见某被墙的网页,说是SSL的证书过时,下载新的ssl本地判别文件
wget http://curl.haxx.se/ca/cacert.pem
并更名为ca-bundle.crt放置到默认目录
mv cacert.pem ca-bundle.crt | mv ca-bundle.crt /etc/pki/tls/certs/
或者curl –cacert cacert.pem 方式指定调用。这是LINUX下的解决方案,我的Deepin2014.3的这样之后就好了。你可以试试下载一下这个证书,然后安装一下呢?
Writing lock file Generating autoload files D:\kadifu\advanced>composer create-project --prefer-dist --stability=dev yiisoft /yii2-app-advanced ../Community Installing yiisoft/yii2-app-advanced (dev-master b0534c270c55217d68f95723a2cb685 5fffe4712) - Installing yiisoft/yii2-app-advanced (dev-master master) Loading from cache Created project in ../Community Loading composer repositories with package information Installing dependencies (including require-dev)
第七步到这里就不动了怎么破?都等了一天了,还是这样。
cmd 关掉 重新执行第7步试试
不行的话 直接下载的yii2 安装好的源码 直接可以用:http://www.yiichina.com/tutorial/359
小马哥,您好,我安装YII2.0到第六步就不行了,能帮我看看吗?
d:\WWW\yii2\advanced>php composer.phar create-project --prefer-dist --stability= dev yiisoft/yii2-app-advanced ../yii2test Installing yiisoft/yii2-app-advanced (dev-master 243a4dfe63a7b9a3f5e15531c3d1c0b e77b49edd) - Installing yiisoft/yii2-app-advanced (dev-master master) Loading from cache Created project in ../yii2test Loading composer repositories with package information Installing dependencies (including require-dev) Could not fetch https://api.github.com/repos/twbs/bootstrap, please create a Git Hub OAuth token to go over the API rate limit Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+ on+Lenovo-wxh+2015-05-12+0324 to retrieve a token. It will be stored in "C:/Users/兴宏/AppData/Roaming/Compose r/auth.json" for future use by Composer. Token (hidden):
composer安装yii2或者laravel报错
http://www.cnsecer.com/6994.html
@caoyuanlianni 我也是 要token 不知道那儿弄这个token
@Rensile 申请github账户个人主页setting-》-》personal access tokens 生成一个输入进去就好了,然后安装就可以继续了
你好,进入测试页面,输入
localhost/yii2/yii2test/frontend/web/index.php
页面显示以下内容:
Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.15
你要是还解决不了的话,直接下载安装好的源码 我有的 试试
若还是不能访问的话
只能说明 只允许直接访问
@小马哥 搞定了,登录github注册进去,生成token复制粘贴进去,成功退出再进入第6步就行了
@改道梁山 您好 token是怎么生成的哇
@promise 注册登录GitHub view profile and more -> settings -> personal access tokens
@改道梁山 token(hidden) 这里没法输入是什么情况?你那里可以输入吗?
安装到第六步就一直不动了,请问网速慢在下载文件,还是什么情况
你好,执行到第六步时,一直报错
could not parse version constraint ../yii2test:Invalid version string "../yii2test"
,求帮助你实在没办法了,还是下载我的安装好的源码吧
D:\yii2>php -r "readfile('https://getcomposer.org/installer');" | php PHP Notice: readfile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1 PHP Warning: readfile(https://getcomposer.org/installer): failed to open stream : Invalid argument in Command line code on line 1 Warning: readfile(https://getcomposer.org/installer): failed to open stream: Inv alid argument in Command line code on line 1
求解决!
访问
http://127.0.0.1:8088/yii2test/frontend/web/
提示
Warning: require(D:\phpWeb\yii2test\frontend\web/../../vendor/autoload.php): failed to open stream: No such file or directory in D:\phpWeb\yii2test\frontend\web\index.php on line 5 Fatal error: require(): Failed opening required 'D:\phpWeb\yii2test\frontend\web/../../vendor/autoload.php' (include_path='.;C:\php\pear') in D:\phpWeb\yii2test\frontend\web\index.php on line 5
你有没有解决这个问题啊,我也遇到了
同求啊!求解决办法
我也遇到这个问题,好像是什么文件没有吧,暂时不知道怎么处理
我也遇到了这样的问题。
加油啦.......
@小马哥 在第6步
“Installing dependencies (including require-dev)”
,这里不往下走了我也是这问题,你解决了吗?我还没得解决
第六步 不往下走应该是:GitHub 的用户名和密码的原因,注册个账号,退出cmd,重新执行第6步
@小马哥 现在是输入token(hidden),可有解?
@kadifu 我也是这个问题,,现在根本不走,,求解答呀
我也遇见这个问题,输入token:
第五步这里的“准备所有插件!!非常重要,少了这步一切都会失败 (!!记得配置php环境变量啊)”
我在官网下载了composer-asset-plugin-1.0压缩包,解压到D:\phpStudy\WWW\yii2\basic目录下,然后再把php.exe的地址和composer-asset-plugin-1.0的地址放进环境变量Path中,这样对否?
然后在cmd里面使用
php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
命令,有错!求帮助
解决了 不用另外下载
composer-asset-plugin-1.0
压缩包,只是要把命令改为“composer global require "fxp/composer-asset-plugin:1.0.0"”
还有一点,我等小白都不知道cmd输入密码是不显示的(蠢哭)
@绵绵姐 额,解决了就好
@小马哥 还有问题,初始化时init命令无效 怎么办?
@绵绵姐 @小马哥。我的是ubuntu安装yii2提示init丢失运行级别
小马哥,我到第四步出现问题:
D:\>cd D:\wamp\www\yii\advanced
D:\wamp\www\yii\advanced>php -r "readfile('https://getcomposer.org/installer');" | php PHP Warning: readfile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. readfile() Command line code:1 PHP Warning: readfile(https://getcomposer.org/installer): failed to open stream : Invalid argument in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. readfile() Command line code:1 Warning: readfile(): Unable to find the wrapper "https" - did you forget to enab le it when you configured PHP? in Command line code on line 1 Call Stack: 0.0020 117080 1. {main}() Command line code:0 0.0020 117472 2. readfile() Command line code:1 Warning: readfile(https://getcomposer.org/installer): failed to open stream: Inv alid argument in Command line code on line 1 Call Stack: 0.0020 117080 1. {main}() Command line code:0 0.0020 117472 2. readfile() Command line code:1 D:\wamp\www\yii\advanced>
不知道怎么回事,求助!
解决了吗 我也出现这个问题
感谢楼主提示,添加了环境变量安装成功了
您好楼主,这个错误要怎么解决呀!谢谢
请问第5步和第6步有什么差别
现在好了,以前第五步是更新yii2代码的,现在都是最新的,不需要第五步了