Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

[ErrorException] Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::whatProvides() should be compatible with Composer\Repository\ComposerRepository::whatProvides(Composer\DependencyResolver\Pool $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"
        }
    }
}
like image 265
Marko Mikulić Avatar asked Apr 05 '16 22:04

Marko Mikulić


3 Answers

About nine days ago (around end of March, 2016), Composer\Repository\ComposerRepository::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
like image 144
Federkun Avatar answered Nov 04 '22 20:11

Federkun


Try this one if update doesn't work.

composer global require fxp/composer-asset-plugin --no-plugins
like image 28
Javid Ahadov Avatar answered Nov 04 '22 20:11

Javid Ahadov


I ended up resolving the issue by removing the fxp directory from the .composer directory. On my setup, this does the trick:

rm -rf ~/.composer/vendor/fxp

Now when something needs it, it can just re-download the updated plugin.

like image 22
Alexander O'Mara Avatar answered Nov 04 '22 20:11

Alexander O'Mara