Font Awesome Asset Bundle for Yii2 framework
This is the Font Awesome extension for Yii framework 2.0. It encapsulates Font Awesome distribution assets and thus makes using Font Awesome in Yii applications extremely easy.
The preferred install way is through Composer:
composer require yidas/yii2-fontawesome
Or you could edit composer.json
with adding package in require section then run composer update
.
"yidas/yii2-fontawesome": "~2.0.0"
Register or depend Asset into your application:
yidas\yii\fontawesome\FontawesomeAsset
For eaxmple, to register Font Awesome assets in view :
\yidas\yii\fontawesome\FontawesomeAsset::register($this);
Or as dependency in your app asset bundle :
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yidas\yii\fontawesome\FontawesomeAsset',
];
}
You could switch Asset to use CDN distribution by configuring config
file:
'components' => [
'assetManager' => [
'bundles' => [
'yidas\yii\fontawesome\FontawesomeAsset' => [
'cdn' => true,
// 'cdnVersion' => '5.11.0',
],
],
],
],
You could also specify CDN source you like:
'assetManager' => [
'bundles' => [
'yidas\yii\fontawesome\FontawesomeAsset' => [
'cdn' => true,
'cdnCSS' => ['//maxcdn.bootstrapcdn.com/font-awesome/5.11.0/css/font-awesome.min.css'],
],
],
],
composer update yidas/yii2-fontawesome
composer update fortawesome/font-awesome
composer require fortawesome/font-awesome 5.11.0