13

I recently ran latest composer installation for a Yii2 basic application template.

But running php composer.phar install throws this exception:

Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

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).

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

[ErrorException]

Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::w hatProvides() should be compatible with Composer\Repository\ComposerRepository:: whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypassFilters = fal se)

Here is my 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": "*"

    },
    "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"
        }
    }
}

What could have gone wrong? Anyone experiencing this?

Ramesh Pareek
  • 1,601
  • 3
  • 30
  • 55

1 Answers1

54

Like the error message says:

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).

Try to update your fxp/composer-asset-plugin:

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

PS: If after update it still not working, try also following:

composer global require fxp/composer-asset-plugin --no-plugins

Bfcm
  • 2,686
  • 2
  • 27
  • 34
  • 1
    I had to run the 2nd command the get rid of the warning, even though I had `"fxp/composer-asset-plugin": "^1.0",` in my `require` section. – Chloe Apr 17 '16 at 03:59
  • 1
    Still the same problem in my composer – Mohammad Aghayari Nov 05 '16 at 11:56
  • 2
    The second step fixed it for me ie the "require" – Harry Jan 11 '17 at 19:26
  • First time Yii2 user here and its ridiculous that it cannot work without so much errors... No wonder nobody takes PHP seriously anymore. I spent half a day just trying to install a framework... – breakline Apr 16 '18 at 17:11
  • disappointed to learn that composer-asset-plugin is still a [real shit](https://github.com/yiisoft/yii2/issues/8688) ! – Ramesh Pareek Oct 26 '19 at 14:29