21

I'm trying to install Yii2 via composer:

composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic

~/.composer/composer.json

{
    "require": {
    "fxp/composer-asset-plugin": "~1.1.1"
    }
}

result:

Problem 1
- yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- Installation request for yiisoft/yii2 >=2.0.5 -> satisfiable by yiisoft/yii2[2.0.5, 2.0.6, dev-master, 2.0.x-dev].

What do I do wrong?

Atanov Vladimir
  • 403
  • 1
  • 5
  • 9

6 Answers6

51
rm -rf ~/.composer/vendor
rm ~/.composer/composer.lock
cd ~/.composer
composer clear-cache
composer self-update
composer global require "fxp/composer-asset-plugin:^1.1.3"
composer install

Then go to your work directory and run:

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

rob006
  • 21,383
  • 5
  • 53
  • 74
aderushev
  • 818
  • 8
  • 11
  • Very interestinmg. I still have problems with this, but you pointed me to the rigth track. My problem was solved on local machine, but when I get to codeship it does not allow me to continue because it spects me to provide the gibhub token, and also wont allow me to run composer self-update. Any Idea? – Pablo Palacios Jun 03 '17 at 22:22
  • if you have old project instead of "composer create-project --prefer-dist yiisoft/yii2-app-basic basic" just do "composer update" – Fadi Nov 20 '18 at 14:35
  • 2
    This solution will not work with PHP 7.4 and Composer 2, it seems. – Olle Härstedt Oct 28 '20 at 08:58
10

You can try the newer version:

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

then:

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

Non-install Bower-Asset way:

You can download Yii2 by Install from an Archive File. By this way you won't need to handle Bower issue.

Further, if you need to update composer without handling Bower, 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"
}

Instead, if you want to create yii2 project without bower-asset issue:

yidas/yii2-app-basic:

composer create-project yidas/yii2-app-basic

yidas/yii2-app-advanced:

composer create-project yidas/yii2-app-advanced


From Yii 2.0.13, it used Asset-Packagist solution instead of fxp/composer-asset-plugin

Nick Tsai
  • 3,799
  • 33
  • 36
7

This problem could be also resolved via

composer require yidas/yii2-bower-asset

More details about this package: https://packagist.org/packages/yidas/yii2-bower-asset

jurgen
  • 79
  • 1
  • 2
1

https://getcomposer.org/Composer-Setup.exe download and install. After installing run this command line in your project folder composer update

Toir
  • 177
  • 1
  • 10
0

First change the .composer permissions

sudo chown -R $USER .composer/

Then

composer global require "fxp/composer-asset-plugin:^1.2.0"
Skatox
  • 4,237
  • 12
  • 42
  • 47
0

Solved. I needed to install the Composer Asset Plugin first:

php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
Skatox
  • 4,237
  • 12
  • 42
  • 47