Cannot update yii2 via composer bower-asset/jquery

2019-01-21 05:16发布

I was updating my yii2 via composer then reverted back to the old beta version.

Here is the error on my composer:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package bower-asset/jquery could not be found in any version, there may be a typ
o in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setti
ng
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Tried searching for bower-asset/jquery at packagist but it is not found.

Thanks for the help :)

7条回答
倾城 Initia
2楼-- · 2019-01-21 05:51

As described in YII2 repository documentation: https://asset-packagist.org/site/about We can solve this problem by adding aliases on those folders in our config. It will looks like that:

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

It works perfectly!

查看更多
Explosion°爆炸
3楼-- · 2019-01-21 05:52

Found a cleaner solution. Just add following repository in your composer.json file

"repositories": [
 {
  "type": "composer",
  "url": "https://asset-packagist.org"
 }
]

and watch the magic

查看更多
别忘想泡老子
4楼-- · 2019-01-21 06:06

Simple and clean solution:

In composer.json just replace the bower-asset/jquery line with: "yidas/yii2-bower-asset":"*"


I propose we add also bower-asset/datatables to the yidas/yii2-bower-asset


My Problems with accepted solution of adding fxp/composer-asset-plugin are that the plugin is significantly slowing down the composer system, impacts everywhere, isn't always portable across operating systems and environments, has errors with PHP7.2 relating to inconsistent method names. So, I prefer my quicker to develop, faster at runtime, more local, and more compatible solution.

查看更多
劫难
5楼-- · 2019-01-21 06:07

Finally fixed it, just followed the steps on the UPGRADE.md doc

If you are using Composer to upgrade Yii, you should run the following command first (once for all) to install the composer-asset-plugin:

composer global require "fxp/composer-asset-plugin:^1.2.0"

(See http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-from-composer for latest version.)

You may also need to add the following code to your project's composer.json file :

"extra": {
    "asset-installer-paths": {
        "npm-asset-library": "vendor/npm",
        "bower-asset-library": "vendor/bower"
    }
}

Hopes this helps :)

查看更多
Evening l夕情丶
6楼-- · 2019-01-21 06:08

If you don't want to use fxp/composer-asset-plugin then all you have to do is to follow these simple instructions from Yii2 documentation.

Using asset-packagist repository

This way will satisfy requirements of the majority of projects, that need NPM or Bower packages.

Note: Since 2.0.13 both Basic and Advanced application templates are pre-configured to use asset-packagist by default, so you can skip this section.

In the composer.json of your project, add the following lines:

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
]

Adjust @npm and @bower aliases in you application configuration:

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

Visit asset-packagist.org to know, how it works.

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-21 06:10

For me helps to remove folder ~/.composer and execute command:

php composer.phar global require "fxp/composer-asset-plugin:1.*"

Then just run again

php composer.phar update
查看更多
登录 后发表回答