配置环境变量(可以省略)
步骤:
1.右击我的电脑-属性-高级-环境变量
2.找到 Path 这一项(可能需要向下滚动才能找到),鼠标双击 Path 这一项,在最后加入你的 PHP 目录和类库所在的路径,包括前面的“;”(例如:;C:\php;C:\php\ext)
3.点击“新建”按钮并在“变量名”中输入“PHPRC”,在“变量值”中输入 php.ini 文件所在的目录(例如:C:\php) ,这个步骤是为了让windows找到php.ini.
然后按照Yii中文网安装步骤走吧
1)先安装composer。(吐槽。MD,安装了几次终于安装好了,需要VPN,下载的时候用其他浏览器下载的安装包容易报错,所以还是用IE或Edge下载安装吧)
2)安装 Composer asset plugin, 它是通过 Composer 管理 bower 和 npm 包所必须的
E:\wamp\wamp64\www\Yii\yii2-app-advanced>composer global require "fxp/composer-asset-plugin:~1.1.1"
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Content-Length mismatch
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
- Installing fxp/composer-asset-plugin (v1.1.4)
Downloading: 100%
Writing lock file
Generating autoload files
3)将 Yii 安装在名为 yii2test 的目录中,你也可以随便选择其他名称。
E:\wamp\wamp64\www\Yii\yii2-app-advanced>composer create-project --prefer-dist yiisoft/yii2-app-advanced ../yii2test
Content-Length mismatch
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Installing yiisoft/yii2-app-advanced (2.0.10)
- Installing yiisoft/yii2-app-advanced (2.0.10)
Downloading: 100%
Created project in ../yii2test
Loading composer repositories with package information
[Composer\Downloader\TransportException]
Your configuration does not allow connections to http://packagist.org/packages.json. See https://getcomposer.org/do
c/06-config.md#secure-http for details.
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]
E:\wamp\wamp64\www\Yii\yii2-app-advanced>
4)最后一步:初始化我们的应用,初始化是在你创建的yii2test目录下 ,在cmd 执行init命令 选0 yes
E:\wamp\wamp64\www\Yii\yii2test>php yii serve
Warning: require(E:\wamp\wamp64\www\Yii\yii2test/vendor/autoload.php): failed to open stream: No such file or directory in E:\wamp\wamp64\www\Yii\yii2test\yii on line 14
Fatal error: require(): Failed opening required 'E:\wamp\wamp64\www\Yii\yii2test/vendor/autoload.php' (include_path='.;C:\php\pear') in E:\wamp\wamp64\www\Yii\yii2test\yii on line 14
出错啦。。。。。。。。。。。。
分析原因:
很多人说是创建的时候下载的包不完全或路径不对
好吧,我重来:
切换到项目的根目录。执行创建,在此过程,可能会提示需要输入token,这个在哪里生产呢?
git token setting 到这里生成贴上去就可以了
E:\wamp\wamp64\www\Yii>composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2test
耐心等待下,应该会提示输入token,贴上github等待下,可能会比较慢,没办法。
完成后,再执行第四步初始化项目。
安装成功后,访问
http://127.0.0.1/Yii/yii2test//frontend/web/index.php
会出现模板界面就可以了
可以参考下方的链接安装
http://www.yiichina.com/doc/guide/2.0/start-installation
安装好烦,速度特别慢,折腾人
clone项目后不能运行
如果是clone公司或开源的项目,里面是没有vendor文件夹的,没有这个文件夹是无法运行的,提示找不到autoload.php什么的。
需要在项目所在目录更新下:
composer update