Do you usually come across the questions like, What isYii / Yii2? How to install it? Check out the blog written by SurajMalve:How To Install Yii2 framework- A Complete Step by Step Guide
What Is an Asset Bundle?
In technical language, Asset Bundles are PHP classes extending from \yii\web\AssetBundle.
Asset bundle makes it easy to group specific Scripts and CSS for specific pages,
Let’s take an example of Password Meter.
Defining an Asset Bundles / Creating an asset bundle
Let’s create a file named “PsmeterAsset.php” in ‘frontend/assets’ folder.
The above PsmeterAsset class specifies that the asset files are located under the @webroot directory which corresponds to the URL @web
If you are willing to put asset files in specific extension OR in bower package you can use @vendor/FILE_PATH OR @bower/FILE_PATH as Base Path respectively
Integrating an Asset Bundle
After creation in order to integrate it with your web page register it in the view file.
Initiate asset bundle in your view file, as shown below:
That’s all, now you can see the result of above asset bundle in below image:
Believe me, Yii2 Asset bundle is pretty easy to manage.