Composer 抛出 [ReflectionException] Class FxpComposerAssetPluginRepositoryNpmRepository 不存在

2022-01-07 00:00:00 php composer-php yii2

我安装了最新版本(1.0.0.稳定版)的composer,并在我的Yii2项目中输入:

php composer.phar 更新

它给了我这个错误:

<块引用>

[ReflectionException] Class FxpComposerAssetPluginRepositoryNpmRepository 不存在

<块引用>

[ErrorException] FxpComposerAssetPluginRepositoryAbstractAssetsRepository::whatProvides() 的声明应该与 ComposerRepositoryComposerRepository::whatProvides(ComposerDependencyResolverPool $pool, $name, $bypassFilters = false 兼容)

有人可以帮我解决这个问题吗?

这是我的 composer.json

<代码>{"name": "yiisoft/yii2-app-advanced","description": "Yii 2 高级项目模板","关键字": ["yii2", "框架", "高级", "项目模板"],"主页": "http://www.yiiframework.com/","类型": "项目","license": "BSD-3-Clause",支持": {"问题": "https://github.com/yiisoft/yii2/issues?state=open","论坛": "http://www.yiiframework.com/forum/","wiki": "http://www.yiiframework.com/wiki/","irc": "irc://irc.freenode.net/yii",来源":https://github.com/yiisoft/yii2"},最低稳定性":稳定",要求": {"php": ">=5.4.0","yiisoft/yii2": ">=2.0.6","yiisoft/yii2-bootstrap": "*","yiisoft/yii2-swiftmailer": "*","kartik-v/yii2-widget-fileinput": "@dev","golonka/bbcodeparser": "^2.2"},需要开发":{"yiisoft/yii2-codeception": "*","yiisoft/yii2-debug": "*","yiisoft/yii2-gii": "*","yiisoft/yii2-faker": "*"},配置":{进程超时":1800},额外的": {资产安装程序路径":{"npm-asset-library": "供应商/npm",凉亭资产库":供应商/凉亭"}}}

解决方案

大约 9 天前(大约 2016 年 3 月下旬),ComposerRepositoryComposerRepository::whatProvides api 发生了变化.(#2668)所以,如果你已经全局安装了 fxp/composer-asset-plugin,你应该更新它.你可以这样做:

php composer.phar 全局更新 fxp/composer-asset-plugin --no-plugins

I installed the latest version (1.0.0. stable) of composer and in my Yii2 project I typed this:

php composer.phar update

It gives me this error:

[ReflectionException] Class FxpComposerAssetPluginRepositoryNpmRepository does not exist

[ErrorException] Declaration of FxpComposerAssetPluginRepositoryAbstractAssetsRepository::whatProvides() should be compatible with ComposerRepositoryComposerRepository::whatProvides(ComposerDependencyResolverPool $pool, $name, $bypassFilters = false)

Can someone help me how to fix this?

Here's my composer.json

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "framework", "advanced", "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.6",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "kartik-v/yii2-widget-fileinput": "@dev",
        "golonka/bbcodeparser": "^2.2"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

解决方案

About nine days ago (around end of March, 2016), ComposerRepositoryComposerRepository::whatProvides api changed. (#2668) So, if you have installed fxp/composer-asset-plugin globally, you should update it. You can do that with:

php composer.phar global update fxp/composer-asset-plugin --no-plugins

相关文章