yii2作曲家更新致命错误

时间:2016-01-26 07:49:47

标签: solr yii2 composer-php

当我更新我的作曲家以向我的项目添加yii2-solr扩展名时,我遇到如下错误:

The "yiisoft/yii2-composer" 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).
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).

PHP Fatal error:  Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272

Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272

之前我已经composer self-update但仍然无法运行,当我想要运行

composer global require "fxp/composer-asset-plugin:1.0.1"

再次出现上述错误。 这是我的composer.json文件内容:

{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
    "issues": "https://github.com/yiisoft/yii2/issues?state=open",
    "forum": "http://www.yiiframework.com/forum/",
    "wiki": "http://www.yiiframework.com/wiki/",
    "irc": "irc://irc.freenode.net/yii",
    "source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
    "php": ">=5.4.0",       
    "yiisoft/yii2": ">=2.0.5",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "filsh/yii2-oauth2-server": "*",
    "johnitvn/yii2-rbac-plus": "*",
    "yiisoft/yii2-sphinx": "^2.0",
    "yiisoft/yii2-solr": "*"
},
"require-dev": {
    "yiisoft/yii2-codeception": "*",
    "yiisoft/yii2-debug": "*",
    "yiisoft/yii2-gii": "*",
    "yiisoft/yii2-faker": "*"
},
"config": {
    "process-timeout": 1800
},
"scripts": {
    "post-create-project-cmd": [
        "yii\\composer\\Installer::postCreateProject"
    ]
},
"extra": {
    "yii\\composer\\Installer::postCreateProject": {
        "setPermission": [
            {
                "runtime": "0777",
                "web/assets": "0777",
                "yii": "0755"
            }
        ],
        "generateCookieValidationKey": [
            "config/web.php"
        ]
    },
    "asset-installer-paths": {
        "npm-asset-library": "vendor/npm",
        "bower-asset-library": "vendor/bower"
    }
}

}

如何修复此错误? 感谢。

4 个答案:

答案 0 :(得分:30)

1)删除旧版本的Composer Asset Plugin:

composer global remove "fxp/composer-asset-plugin"

2)安装较新版本。现在推荐的安装版本(截至撰写本文时)1.1.1(参见official docs)。

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

我甚至建议使用:

composer global require "fxp/composer-asset-plugin:*"

3)在项目文件夹中运行composer install。如果出现错误,请删除vendor文件夹内容和composer.lock文件,然后再次运行composer install

答案 1 :(得分:5)

如果arogachev的答案对你不起作用,这里有一个快速解决方法。

  1. 手动删除全局编辑器安装中的vendor文件夹。要删除的文件夹,例如。在ubuntu上:/home/user/.composer/vendor
  2. 安装较新版本的插件
  3. composer global require "fxp/composer-asset-plugin:*"

    应该是全部。您将获得所有文件,然后继续

答案 2 :(得分:0)

Bower-Asset跳过方式:

您可以在yidas/yii2-composer-bower-skip文件中yiisoft/yii2之前composer.json要求{/ 1}}:

"require": {
    "php": ">=5.4.0",      
    "yidas/yii2-composer-bower-skip": "~2.0.0", 
    "yiisoft/yii2": ">=2.0.5",
    "yiisoft/yii2-bootstrap": "*",
    ...

然后运行composer update

这种情况是因为您不需要Bower的更新。

  

请参阅https://github.com/yidas/yii2-composer-bower-skip

答案 3 :(得分:0)

将 composer 回滚到 1.x 版本 - 所述插件(尚)不适用于 composer 2.x(如here 所述):

sudo composer self-update --rollback