Benjamin
Benjamin

Reputation: 154

how upgrade yii bootstrap 3 to bootstrap 5

I have a simple project in bootstrap 3 now I would like upgrade to bootstrap 5, but when I try install bootstrap 5 I get an error.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - yiisoft/yii2-bootstrap[2.0.9, ..., 2.0.11] require bower-asset/bootstrap 3.4.* | 3.3.* | 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, ..., v3.4.1].
    - yiisoft/yii2-bootstrap[2.0.1, ..., 2.0.8] require bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, ..., v3.3.7].
    - yiisoft/yii2-bootstrap 2.0.0 requires bower-asset/bootstrap 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, v3.1.1, v3.2.0].
    - You can only install one version of a package, so only one of these can be installed: bower-asset/bootstrap[v3.1.0, ..., v3.4.1, v4.0.0, ..., v4.6.2, v5.0.0, ..., v5.2.0].
    - yiisoft/yii2-bootstrap5[2.0.1, ..., 2.0.3] require bower-asset/bootstrap ^5.1.0 -> satisfiable by bower-asset/bootstrap[v5.1.0, ..., v5.2.0].
    - Root composer.json requires yiisoft/yii2-bootstrap5 * -> satisfiable by yiisoft/yii2-bootstrap5[2.0.1, 2.0.2, 2.0.3].
    - Root composer.json requires yiisoft/yii2-bootstrap ~2.0.0 -> satisfiable by yiisoft/yii2-bootstrap[2.0.0, ..., 2.0.11].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

This is part of my composer.json

Upvotes: 1

Views: 2847

Answers (3)

David rnk
David rnk

Reputation: 111

  1. Verify that no other packages depend on yiisoft/yii2-bootstrap by running the command:

composer why yiisoft/yii2-bootstrap

It will give you a list of packages that depend on yiisoft/yii2-bootstrap, check that those packages are compatible with yiisoft/yii2-bootstrap5, if not, you should look for another alternative or stay with yiisoft/yii2-bootstrap.

In case you want to remove those packages use composer remove [package].

  1. Si no existe ninguna dependencia de yiisoft/yii2-bootstrap...

composer remove yiisoft/yii2-bootstrap

  1. Then install yiisoft/yii2-bootstrap5

composer require --prefer-dist yiisoft/yii2-bootstrap5:"^2.0"

  1. Finally update all packages if necessary

composer require --prefer-dist yiisoft/yii2-bootstrap5:"^2.0"

Upvotes: 0

composer remove yiisoft/yii2-bootstrap
composer require yiisoft/yii2-bootstrap5

Then you will need to do some modifications in your code. I'll list some here

  • Run a search/replace for yii\bootstrap and replace for yii\bootstrap5. Mainly in view files. But others maybe...
  • Change the HTML markup for layout and manually defined classes. In the case of "widgets", by using those in the yii\bootstrapX extension, the migration is almost transparent.

Upvotes: 2

Benjamin
Benjamin

Reputation: 154

I have to delete "yiisoft/yii2-bootstrap": "~2.0.0", or similar line into composer. Don't should exists both bootstrap versions.

Upvotes: 0

Related Questions