Downgrading from bootstrap 4 to 3 in yii2

Deadly 提交于 2021-01-07 01:21:41

问题


I was currently working on a project using the yii2 framework. I wanted to try out using bootstrap 4.0 with my project and added "yiisoft/yii2-bootstrap": "~2.1.0@dev" to my composer.json file and ran composer update.

This successfully installed bootstrap 4.0.0 in the project but when I started to browse my project to see what was affected I realized that the yii\bootstrap\Modal component was not working.

Because of this, I want to revert my project back to using bootstrap 3 and changed my entry in the composer.json file to "yiisoft/yii2-bootstrap": "~2.0.0" and did a composer update but got the following error

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

  Problem 1
    - yiisoft/yii2-bootstrap 2.0.8 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.7 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.6 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.5 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.4 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.3 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.2 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.1 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
    - yiisoft/yii2-bootstrap 2.0.0 requires bower-asset/bootstrap 3.2.* | 3.1.* -> no matching package found.
    - Installation request for yiisoft/yii2-bootstrap ~2.0.0 -> satisfiable by yiisoft/yii2-bootstrap[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8].

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.

Is there something that I'm doing wrong or is there another way I can downgrade back to bootstrap 3?

Thanks for any suggestions you might have.


回答1:


You can map the assetManager to load the specific versions for the jquery and bootstrap files I also did the same in my previous project, I kept everything up to date and just used the following configurations to load the bootstrap 3 files, you can add the below under components in frontend/config/main.php.

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'sourcePath' => null , 'js' => [ '//code.jquery.com/jquery-2.2.4.min.js' ] ,
        ] ,
        'yii\bootstrap\BootstrapAsset' => [
            'sourcePath' => null , 'css' => [ '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' ] ,
        ] ,
        'yii\bootstrap\BootstrapPluginAsset' => [
            'sourcePath' => null , 'js' => [ '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' ] ,
        ] ,
    ] ,
] ,



回答2:


If you're using fxpio/composer-asset-plugin, this is a known issue.

You can solve this in 2 ways:

  1. Remove vendor directory and composer.lock file, and then run composer update.
  2. Switch to asset-packagist - you will need to uninstall fxpio/composer-asset-plugin and add repository to your composer. More details you can find in Yii documentation.


来源:https://stackoverflow.com/questions/49883306/downgrading-from-bootstrap-4-to-3-in-yii2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!