Composer 抛出类 Fxp Composer AssetPlugin Repository NpmRepository 不存在

我安装了最新版本(1.0. 稳定版)的作曲家和在我的 Yii2项目我输入如下:

php composer.phar update

它给了我这个错误:

类 Fxp Composer AssetPlugin Repository NpmRepository 不存在

[ ErrorException ] Fxp Composer AssetPlugin Repository AbstractAssetsRepository 的声明: : whatRules ()应该与 Composer Repository ComposerRepository: : whatprovision (Composer DependencyResolver Pool $Pool,$name,$byassFilters = false)兼容

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

这是我的作曲家 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"
}
}
}
36785 次浏览

大约九天前(2016年3月底左右) ,Composer\Repository\ComposerRepository::whatProvides api 发生了变化 因此,如果你在全球范围内安装了 fxp/composer-asset-plugin,你应该更新它。你可以这样做:

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

如果更新不起作用,试试这个。

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

您可以通过在全局级别上要求它来进行永久性的修复,然后对于其他每个项目都可以解决这个问题。但是一定要把这个消息告诉你所有的团队成员。

最好是在项目范围内添加这个,这样就可以解决所有人的问题。

所以:

composer require fxp/composer-asset-plugin

最后,我通过从 .composer目录中删除 fxp目录来解决这个问题。在我的设置中,这样做的诀窍:

rm -rf ~/.composer/vendor/fxp

现在,当某些东西需要它时,它可以重新下载更新后的插件。

运行以下命令编辑全局 composer.json:

然后确保上面有这条线:

{
"require": {
"fxp/composer-asset-plugin": "1.1.*"
}
}

上面的答案对我来说不起作用,因为我的 fxp/composer-asset-plugin版本就像 1.1-beta04,当我把它改成 "1.1.8"并运行 update 命令时:

php /usr/bin/composer global update fxp/composer-asset-plugin --no-plugins

它解决了这个问题。但是没有编辑我的全局 composer.json,它给了我这个错误:

无法将您的需求解决为一组可安装的包。

问题1 - fxp/writer-asset-plugin 1.0.0-beta3的安装请求-> 可由 fxp/writer-asset-plugin [ v1.0.0-beta3]满足。 - fxp/writer-asset-plugin v1.0.0-beta3需要 writer-plugin-api 1.0.0-> 没有找到匹配的包。

潜在原因: - 软件包名称中的输入错误 - 根据您的最小稳定性设置,该软件包没有足够稳定的版本 详情请参阅 https://getcomposer.org/doc/04-schema.md#minimum-stability

阅读 https://getcomposer.org/doc/articles/troubleshooting.md了解更多常见问题。

在我的案例项目一二

$ composer


[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\ComposerRepo
sitory::whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypass
Filters = false)

Yii2,在文件夹 vendor/fxp中你需要替换文件夹 composer-asset-plugin或删除它。

如果没有其他解决方案适合您,请尝试 资产包装师作为替代。

  1. 像下面这样将 包裹 鲍尔资产/引导程序Npm-asset/jquery添加到 comper.json:

    "require": {
    "bower-asset/bootstrap": "^3.3",
    "npm-asset/jquery": "^2.2"
    }
    
  2. Add a repositories block (if you still don't have one, if you do, just append to it) with the following content:

    "repositories": [
    {
    "type": "composer",
    "url": "https://asset-packagist.org"
    }
    ]
    
  3. Run composer install (or composer update)

  4. Considering that asset-packagist installs assets in a different directory, add the following lines to your application config (usually called as web.php):

    $config = [
    'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset',
    ],
    ];
    

These instructions may change over time. They have been copied from the repo website so they could last in time just in case something happens to the website. I am not the author of the repo but I really appreciate the effort made into it. Please check https://asset-packagist.org/site/about to know more about the project.


If you are struggling with composer, here you have some useful commands:

composer clear-cache - Clear composer related caches

composer install -vvv - Add the parameter "vvv" to show installation process related output (useful to debug)

composer global show - Useful to check if you already have fxp/composer-asset-plugin installed. In my case, it already was, however it was not being detected as a dependency, and the solution I described earlier worked flawless to me - hope it does work for you too!