BS3 to BS4 - what to do about BS3 composer packages?

Hello. Yii2 is awesome and I’m very glad I chose this MVC framework. I have some issues moving from boostrap3 to bootstrap4. I found the libs that require BS3 by just seaching for the calls in composer.json and/or the assets file.

Some of the composer packages call BS3 and are not aware of BS4/5. Some do, such as Kartik’s great plugins, but most do not. Is there any graceful way to use BS3 plugins without loading BS3 CSS/JS?

Options I can think of:

  1. Modify the libs composer.json/asset calls to look for boostrap4, then copy to vendor directory. This is an ugly hack.
  2. Find alternatives to each one. About 6 of them are BS3 only, so finding alternatives may be possible, but many just haven’t been updated for BS4.
  3. Clone the repos for each lib, make them BS4 aware and publish them myself as composer libs.

Any suggestions would be great from the community!
Thank you.

This will not work, composer does not look at the composer.json files in the vendor directory, it only uses the metadata from packagist when resolving dependencies.
Also simply replacing the dependencies is not enough, BS 4 and 5 require some changes in HTML structure and renaming of CSS classes to work properly.

In most cases it would be required to use an alternative or updated version for newer bootstrap version. As I said, it is not enough to replace the CSS, you also need to adjust HTML structure and CSS class names.

Before forking the repo yourself it might be better to ask the maintainer of the libraries if they plan to update for newer bootstrap versions and if they accept pull requests for changes.

1 Like

Yeah, you are right. You share the same headache with me.

1 Like

I’ll still be searching for options. For now, I just copied all the composer libs that make calls to BS3 and changed the source to require yiisoft/yii2-bootstrap4 and related asset calls. Seems to work, but like you said, some of the HTML/CSS calls need to be modified as well. But hey, that’s what open source is all about, right? If it’s broken, you can fix it with a little or a lot of effort. :slight_smile: