Composer抛出类Fxp \ Composer \ AssetPlugin \ Repository \ NpmRepository不存在
我安装了composer php的最新版本(1.0.0。stable),并在我的Yii2项目中input了这个:
php composer.phar update
它给了我这个错误:
[ReflectionException]类Fxp \ Composer \ AssetPlugin \ Repository \ NpmRepository不存在
(Error Composer \ Composer \ AssetPlugin \ Repository \ AbstractAssetsRepository :: whatProvides()应与Composer \ Repository \ ComposerRepository :: whatProvides兼容
有人可以帮我解决这个问题吗?
这是我的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" } } }
大约九天前, Composer\Repository\ComposerRepository::whatProvides
api改变了。 ( #2668 )所以,如果你已经全局安装了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
目录中删除fxp
目录来解决问题。 在我的设置,这是诀窍:
rm -rf ~/.composer/vendor/fxp
现在什么时候需要它,它可以重新下载更新的插件。
尝试编辑您的全球composer.json
运行:
vi ~/.composer/composer.json
然后确保你有这条线:
{ "require": { "fxp/composer-asset-plugin": "1.1.*" } }
上面的答案不适用于我,因为我的fxp/composer-asset-plugin
是1.1-beta04
,当我将其更改为"1.1.8"
并运行更新命令时:
php /usr/bin/composer global update fxp/composer-asset-plugin --no-plugins
它解决了这个问题。 但没有编辑我的全球composer.json
,它给了我这个错误:
Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for fxp/composer-asset-plugin 1.0.0-beta3 -> satisfiable by fxp/composer-asset-plugin[v1.0.0-beta3]. - fxp/composer-asset-plugin v1.0.0-beta3 requires composer-plugin-api 1.0.0 -> no matching package found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details. Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
在我的Yii2案例中
[isv@hosting]$ 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
”文件夹中,您需要replace文件夹“ composer-asset-plugin
”或删除
如果没有其他解决scheme为您工作,请尝试AssetPackagist作为替代。
-
将包 bower-asset / bootstrap和npm-asset / jquery添加到composer.json中,如下所示:
"require": { "bower-asset/bootstrap": "^3.3", "npm-asset/jquery": "^2.2" }
-
添加一个存储库块(如果你还没有,只需附加到它)与以下内容:
"repositories": [ { "type": "composer", "url": "https://asset-packagist.org" } ]
-
运行
composer install
(或composer update
) -
考虑到asset-packagist将资产安装在不同的目录中,请将以下行添加到应用程序configuration(通常称为web.php)中:
$config = [ 'aliases' => [ '@bower' => '@vendor/bower-asset', '@npm' => '@vendor/npm-asset', ], ];
这些说明可能随时间而改变。 他们已经从回购网站复制,所以他们可以持续时间,以防万一网站发生了什么事情。 我不是回购商的作者,但我非常感谢他们付出的努力。 请查看https://asset-packagist.org/site/about了解更多关于该项目的信息。;
如果你正在与composer php苦苦挣扎,这里有一些有用的命令:
composer clear-cache
– 清除composer php相关的caching
composer install -vvv
– 添加参数“vvv”显示安装过程相关的输出(对debugging有用)
composer global show
– 有用的检查,如果你已经安装了fxp / composer-asset-plugin 。 就我而言,现在已经是这样了,但是它并没有被检测为依赖,我之前描述的解决scheme对我来说是完美无缺的 – 希望它对您也有用!
您可以通过在全球范围内进行永久性修复,然后解决其他所有项目。 但是,请确保您将小费给所有的小组成员。
最好的做法是在项目范围内添加这个项目,并以此解决所有问题。
所以:
composer require fxp/composer-asset-plugin