您当前的位置:首页 > 分类 > 技术资讯 > YII > 正文

YII2安装过程中经常遇到的问题

发布时间:2016-04-19 15:30:02      来源:51推一把
【摘要】列举yii2安装过程中经常遇到的几个问题,希望能让大家少走弯路
1.需要设置全局模式

有时候composer install/update的时候会报错:
[Composer\Downloader\TransportException]                                                                                                                          
Your configuration does not allow connection to http://ooxx/xxoo.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.

解决方法是设置一个本地或全局的composer配置:
composer config secure-http false

全局设置:
composer config -g secure-http false
意义是默认禁用https请求,就可以了

2.安装遇到提示输入token问题

根据lead to 后面的url去github获取token,到了那个页面以后 点击表单下面的Generate token 按钮 生成token

3.安装Composer Asset插件老是失败

安装完Composer,运行下面的命令来安装Composer Asset插件

运行 php composer.phar global require "fxp/composer-asset-plugin:~1.0.0"

错误提示
PHP Fatal error:  Call to undefined method Composer\Package\Version\VersionParser::parseLinks() in /home/yiyi/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 270
Fatal error: Call to undefined method Composer\Package\Version\VersionParser::parseLinks() in /home/yiyi/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 270

建议更新composer,并且用php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"当前比较新的版本

4.windows下 composer常见错误及处理。

错误一:
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "C:\ProgramData\ComposerSetup\bin\composer.phar self-update" to get the latest version.

解决方法:

composer selfupdate

如下图:

错误二:

You are running composer with xdebug enabled. This has a major impact on runtime
performance. See https://getcomposer.org/xdebug

如图:



解决方法:

打开php.ini,在zend_extension前加分号

;zend_extension = "d:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
见文档:

https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer

错误三:
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\V
ersionParser::parseLinks() in C:\Documents and Settings\Administrator\Applicatio
n Data\Composer\vendor\fxp\composer-asset-plugin\Repository\VcsPackageFilter.php
on line 272

解决办法:

删除composer资源插件,再重新安装

Linux : rm -rf ~/.composer/vendor/fxp

Windows : rm -r %APPDATA%\Composer\vendor\fxp

重新安装:

composer global require "fxp/composer-asset-plugin:~1.0.3"
如果还有其它错误,可尝试全局更新:

composer global update
见参考:

http://stackoverflow.com/questions/32901750/why-do-i-get-php-fatal-error-when-i-want-to-install-an-extension

windows截图如下:



错误四:
The "yiisoft/yii2-composer" plugin requires composer-plugin-api 1.0.0, this *WIL L* break in the future and it should be fixed ASAP (require ^1.0 for example). 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 ).

解决办法:
Yii2 需要 composer-plugin-api 1.0 以上的版本,运行以下命令:
composer global require "fxp/composer-asset-plugin:~1.1.1"

更多信息参考:
composer 中文网:http://www.phpcomposer.com/
composer官网:https://getcomposer.org/doc/