DEV Community

zohanto
zohanto

Posted on

4 2

Change bootstrap theme in Yii2 Apllication

Yii2 is a PHP framework that until now, april 2021, still use bootstrap 3. If you are okay with that, then Yii2 is an awesome framework. Yii2 give you flexibility to handle javascript and css through AssetBundle, a feature that i didnt found in another major framework like laravel, symphony etc.

BootstrapAsset is Yii2 AssetBundle to handle bootstrap css. Luckily we can configure the BootstrapAsset through web.php config file. Say that you want to apply theme to the bootstrap 3 you already have. You got a cool free theme from bootswatch.com and want apply that to your Yii2 apps. So this is what you need to do.

  1. create folder inside @app/views folder for example we create 'flatly' folder here for your flatly theme

  2. create 'css' folder inside the previous

  3. create 'bootstrap.css' file inside the 'css' folder then copy the theme style into this file

  4. add bellow line at the end of if (YII_ENV_DEV) definition inside the web.php config file

$config['components']['assetManager']['bundles']['yii\bootstrap\BootstrapAsset']['sourcePath'] = '@app/views/flatly';
Enter fullscreen mode Exit fullscreen mode

thats it

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay