Cannot update yii2 via composer bower-asset/jquery could not be found

后端 未结 7 2082
野趣味
野趣味 2020-12-12 16:54

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          


        
相关标签:
7条回答
  • 2020-12-12 17:30

    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.

    0 讨论(0)
  • 2020-12-12 17:35

    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.

    0 讨论(0)
  • 2020-12-12 17:39

    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
    
    0 讨论(0)
  • 2020-12-12 17:42

    If you don't need the update for bower-asset, you can require yidas/yii2-composer-bower-skip before yiisoft/yii2. in composer.json file:

    "require": {
        "php": ">=5.4.0",
        "yidas/yii2-composer-bower-skip": "~2.0.0",
        "yiisoft/yii2": "~2.0.5",
        "yiisoft/yii2-bootstrap": "~2.0.0"
    }
    

    After that, you can update Composer smoothly without bower-asset.

    See https://github.com/yidas/yii2-composer-bower-skip

    0 讨论(0)
  • 2020-12-12 17:47

    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!

    0 讨论(0)
  • 2020-12-12 17:48

    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

    0 讨论(0)
提交回复
热议问题