AssetBundle represents a collection of asset files, such as CSS, JS, etc.
An asset bundle can depend on other asset bundles. When registering an asset bundle with a view, all its dependent asset bundles will be automatically registered.
please refer below link
Yii2 AssetBundle API DOC
AssetBundle Example
First create one ThemeAsset
AssetBundule.
<?php
namespace appassets;
use yiiwebAssetBundle;
class ThemeAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'/themes/dcu/assets/css/bootstrap.css',
'/themes/dcu/assets/css/bootstrap-responsive.min.css',
'/themes/dcu/assets/css/gbu.css',
'/themes/dcu/assets/css/font-awesome.css',
];
public $js = [
....
js file here
....
];
public $jsOptions = [
....
js options here
....
];
public $depends = [
....
dependent asset bundles here
eg: 'yiiootstrapBootstrapAsset'
....
];
}
?>
Now register the ThemeAsset
in your view file
<?php
use appassetsThemeAsset;
ThemeAsset::register($this);
?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…