pengleihp 2016-06-07 14:09:40 13487次浏览 1条评论 3 1 0

按照官网的安装程序,可能出现的错误及常见解决办法
1.首先安装composer报错
1)下载composer.exe慢,提供下载地址:
链接:http://pan.baidu.com/s/1c2Dgsgw 密码:nwak
2)首先需要打开php.ini中的

extension=php_openssl.dll

3)需要需要加载apache下的

LoadModule ssl_module modules/mod_ssl.so

然后重启apache,再重新安装composer

2.按官方文档使用Composer安装Yii时,执行命令:

composer global require "fxp/composer-asset-plugin:~1.0.0"

会出现以下错误

C:\Users\JMJ>composer global require "fxp/composer-asset-plugin:~1.0.0"
Changed current directory to C:/Users/JMJ/AppData/Roaming/Composer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing fxp/composer-asset-plugin (v1.0.3)
    Downloading: 100%

Deprecation Notice: The Composer\Package\LinkConstraint\MultiConstraint class is deprecated, use Composer\Semver\Constraint\MultiConstraint instead. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Package/LinkConstraint/MultiConstraint.php:17
Deprecation Notice: The Composer\Package\LinkConstraint\LinkConstraintInterface interface is deprecated, use Composer\Semver\Constraint\ConstraintInterface instead. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php:17
Plugin installation failed, rolling back
  - Removing fxp/composer-asset-plugin (v1.0.3)

Installation failed, deleting ./composer.json.


  [ReflectionException]
  Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist



  [ErrorException]
  Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::whatProvides() should be compatible wi
  th Composer\Repository\ComposerRepository::whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypassFilte
  rs = false)


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

解决办法:
更新到最新版本即可:

composer global require "fxp/composer-asset-plugin:~1.1"

当时出错时,解决插件问题,参考原文地址:http://blog.weixiaodeyu.com/class-npmrepository-does-not-exist.html

3.发现生成的目录,没有vendor
解决办法:先进入网站目录,然后composer update
更新的时间有点长
在windows中用cmd进入目录的方法,请自行搜索

4.用composer upate时会出现Hub OAuth token to go over the API rate limit,需要Github账号,登录后,在下面的链接中
获取一个token,并输入

https://github.com/settings/tokens/new

5.测试yii是否安装成功
出现如下错误

yii\web\Request::cookieValidationKey must be configured with a secret key.

解决办法:
找到config/文件夹下的web.config文件,找到cookieValidationKey,并随便赋予一个值

这时候看到
Congratulations!
You have successfully created your Yii-powered application.

表示yii2安装成功了

觉得很赞
您需要登录后才可以评论。登录 | 立即注册