2017 © Pedro Peláez
 

yii2-extension yii2-fontawesome

Asset Bundle for Yii2 with Font Awesome

image

rmrevin/yii2-fontawesome

Asset Bundle for Yii2 with Font Awesome

  • Wednesday, July 11, 2018
  • by rmrevin
  • Repository
  • 16 Watchers
  • 129 Stars
  • 552,402 Installations
  • PHP
  • 133 Dependents
  • 1 Suggesters
  • 37 Forks
  • 2 Open issues
  • 55 Versions
  • 9 % Grown

The README.md

Yii 2 Font Awesome Asset Bundle

This extension provides a assets bundle with Font Awesome for Yii framework 2.0 applications and helper to use icons., (*1)

For license information check the LICENSE-file., (*2)

License Latest Stable Version Latest Unstable Version Total Downloads, (*3)

Code Status

Scrutinizer Code Quality Code Coverage Travis CI Build Status Dependency Status, (*4)

Support

Fontawesome version

Version of font-awesome Version of extension
4.* ~2.17
5.* ~3.0

Update to 3.2

Be careful in version 3.2 rmrevin\yii\fontawesome\AssetBundle package use cdn by default. More in the changelog., (*5)

Update to 3.0

Be careful in version 3.0 deprecated methods were removed. More in the changelog., (*6)

Update to 2.17

Be careful in version 2.17 deprecated methods were removed. More in the changelog., (*7)

Installation

The preferred way to install this extension is through composer., (*8)

Either run, (*9)

composer require "rmrevin/yii2-fontawesome:~3.5"

or add, (*10)

"rmrevin/yii2-fontawesome": "~3.5",

to the require section of your composer.json file., (*11)

Usage with fa pro version

CDN

Register your domain here - https://fontawesome.com/how-to-use/on-the-web/setup/getting-started, (*12)

Add CdnProAssetBundle as depends of your app asset bundle:, (*13)

class AppAsset extends AssetBundle
{
    // ...

    public $depends = [
        // ...
        'rmrevin\yii\fontawesome\CdnProAssetBundle'
    ];
}

Or inject CdnProAssetBundle in your view:, (*14)

\rmrevin\yii\fontawesome\CdnProAssetBundle::register($this);

NPM

Install npm package of font:, (*15)

npm install @fortawesome/fontawesome-pro

or, (*16)

yarn add @fortawesome/fontawesome-pro

And add NpmProAssetBundle as depends of your app asset bundle:, (*17)

class AppAsset extends AssetBundle
{
    // ...

    public $depends = [
        // ...
        'rmrevin\yii\fontawesome\NpmProAssetBundle'
    ];
}

Or inject NpmProAssetBundle in your view:, (*18)

rmrevin\yii\fontawesome\NpmProAssetBundle::register($this);

Optional

In order for do not install the free version of the font-awesome package, you can add it to the replace section of composer.json., (*19)

  "replace": {
    "fortawesome/font-awesome": "*"
  },

Usage with fa free version

CDN

Add CdnFreeAssetBundle as depends of your app asset bundle:, (*20)

class AppAsset extends AssetBundle
{
    // ...

    public $depends = [
        // ...
        'rmrevin\yii\fontawesome\CdnFreeAssetBundle'
    ];
}

Or inject CdnFreeAssetBundle in your view:, (*21)

rmrevin\yii\fontawesome\CdnFreeAssetBundle::register($this);

Composer

Free version of package fortawesome/font-awesome already installed in vendor., (*22)

Add NpmFreeAssetBundle as depends of your app asset bundle:, (*23)

class AppAsset extends AssetBundle
{
    // ...

    public $depends = [
        // ...
        'rmrevin\yii\fontawesome\NpmFreeAssetBundle'
    ];
}

Or inject NpmFreeAssetBundle in your view:, (*24)

rmrevin\yii\fontawesome\NpmFreeAssetBundle::register($this);

Class reference

Namespace: rmrevin\yii\fontawesome;, (*25)

Class FAB, FAL, FAR, FAS or FontAwesome

  • static FAR::icon($name, $options=[]) - Creates an component\Icon that can be used to FontAwesome html icon
    • $name - name of icon in font awesome set.
    • $options - additional attributes for i.fa html tag.
  • static FAR::stack($name, $options=[]) - Creates an component\Stack that can be used to FontAwesome html icon
    • $options - additional attributes for span.fa-stack html tag.

Class component\Icon

  • (string)$Icon - render icon
  • $Icon->addCssClass($value) - add to html tag css class in $value
    • $value - name of css class
  • $Icon->inverse() - add to html tag css class fa-inverse
  • $Icon->spin() - add to html tag css class fa-spin
  • $Icon->fixedWidth() - add to html tag css class fa-fw
  • $Icon->ul() - add to html tag css class fa-ul
  • $Icon->li() - add to html tag css class fa-li
  • $Icon->border() - add to html tag css class fa-border
  • $Icon->pullLeft() - add to html tag css class pull-left
  • $Icon->pullRight() - add to html tag css class pull-right
  • $Icon->size($value) - add to html tag css class with size
    • $value - size value (variants: FA::SIZE_LARGE, FA::SIZE_2X, FA::SIZE_3X, FA::SIZE_4X, FA::SIZE_5X)
  • $Icon->rotate($value) - add to html tag css class with rotate
    • $value - rotate value (variants: FA::ROTATE_90, FA::ROTATE_180, FA::ROTATE_270)
  • $Icon->flip($value) - add to html tag css class with rotate
    • $value - flip value (variants: FA::FLIP_HORIZONTAL, FA::FLIP_VERTICAL)

Class component\Stack

  • (string)$Stack - render icon stack
  • $Stack->icon($icon, $options=[]) - set icon for stack
    • $icon - name of icon or component\Icon object
    • $options - additional attributes for icon html tag.
  • $Stack->icon($icon, $options=[]) - set background icon for stack
    • $icon - name of icon or component\Icon object
    • $options - additional attributes for icon html tag.

Helper examples

use rmrevin\yii\fontawesome\FAS;
// or (only in pro version https://fontawesome.com/pro)
// use rmrevin\yii\fontawesome\FAR;
// use rmrevin\yii\fontawesome\FAL;
// use rmrevin\yii\fontawesome\FAB;

// normal use
echo FAS::icon('home'); // <i class="fas fa-home"></i>

// shortcut
echo FAS::i('home'); // <i class="fas fa-home"></i>

// icon with additional attributes
echo FAS::icon(
    'arrow-left', 
    ['class' => 'big', 'data-role' => 'arrow']
); // <i class="big fas fa-arrow-left" data-role="arrow"></i>

// icon in button
echo Html::submitButton(
    Yii::t('app', '{icon} Save', ['icon' => FAS::icon('check')])
); // <button type="submit"><i class="fas fa-check"></i> Save</button>

// icon with additional methods
echo FAS::icon('cog')->inverse();    // <i class="fas fa-cog fa-inverse"></i>
echo FAS::icon('cog')->spin();       // <i class="fas fa-cog fa-spin"></i>
echo FAS::icon('cog')->fixedWidth(); // <i class="fas fa-cog fa-fw"></i>
echo FAS::icon('cog')->li();         // <i class="fas fa-cog fa-li"></i>
echo FAS::icon('cog')->border();     // <i class="fas fa-cog fa-border"></i>
echo FAS::icon('cog')->pullLeft();   // <i class="fas fa-cog pull-left"></i>
echo FAS::icon('cog')->pullRight();  // <i class="fas fa-cog pull-right"></i>

// icon size
echo FAS::icon('cog')->size(FAS::SIZE_3X);
// values: FAS::SIZE_LARGE, FAS::SIZE_2X, FAS::SIZE_3X, FAS::SIZE_4X, FAS::SIZE_5X
// <i class="fas fa-cog fa-size-3x"></i>

// icon rotate
echo FAS::icon('cog')->rotate(FAS::ROTATE_90); 
// values: FAS::ROTATE_90, FAS::ROTATE_180, FAS::ROTATE_180
// <i class="fas fa-cog fa-rotate-90"></i>

// icon flip
echo FAS::icon('cog')->flip(FAS::FLIP_VERTICAL); 
// values: FAS::FLIP_HORIZONTAL, FAS::FLIP_VERTICAL
// <i class="fas fa-cog fa-flip-vertical"></i>

// icon with multiple methods
echo FAS::icon('cog')
        ->spin()
        ->fixedWidth()
        ->pullLeft()
        ->size(FAS::SIZE_LARGE);
// <i class="fas fa-cog fa-spin fa-fw pull-left fa-size-lg"></i>

// icons stack
echo FAS::stack()
        ->icon('twitter')
        ->on('square-o');
// <span class="fa-stack">
//   <i class="fas fa-square-o fa-stack-2x"></i>
//   <i class="fas fa-twitter fa-stack-1x"></i>
// </span>

// icons stack with additional attributes
echo FAS::stack(['data-role' => 'stacked-icon'])
     ->on(FAS::Icon('square')->inverse())
     ->icon(FAS::Icon('cog')->spin());
// <span class="fa-stack" data-role="stacked-icon">
//   <i class="fas fa-square-o fa-inverse fa-stack-2x"></i>
//   <i class="fas fa-cog fa-spin fa-stack-1x"></i>
// </span>

// Stacking text and icons
echo FAS::stack()
     ->on(FAS::Icon('square'))
     ->text('1');
// <span class="fa-stack">
//   <i class="fas fa-square fa-stack-2x"></i>
//   <span class="fa-stack-1x">1</span>
// </span>

// Stacking text and icons with options
echo FAS::stack()
     ->on(FAS::Icon('square'))
     ->text('1', ['tag'=>'strong', 'class'=>'stacked-text']);
// <span class="fa-stack">
//   <i class="fas fa-square fa-stack-2x"></i>
//   <strong class="stacked-text fa-stack-1x">1</strong>
// </span>
// Now you can add some css for vertical text positioning:
.stacked-text { margin-top: .3em; }

// unordered list icons 
echo FAS::ul(['data-role' => 'unordered-list'])
     ->item('Bullet item', ['icon' => 'circle'])
     ->item('Checked item', ['icon' => 'check']);
// 

<

ul class="fa-ul" data-role="unordered-list">
//   <li><i class="fas fa-circle fa-li"></i>Bullet item</li>
//   <li><i class="fas fa-check fa-li"></i>Checked Item</li>
// </span>

// autocomplete icons name in IDE
echo FAS::icon(FAS::_COG);
echo FAS::icon(FAS::_DESKTOP);
echo FAS::stack()
     ->on(FAS::_CIRCLE_O)
     ->icon(FAS::_TWITTER);

The Versions

11/07 2018

dev-master

9999999-dev

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle yii asset font awesome

11/07 2018

3.1.0

3.1.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle yii asset font awesome

01/04 2018

3.x-dev

3.9999999.9999999.9999999-dev

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle yii asset font awesome

01/04 2018

3.0.0

3.0.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle yii asset font awesome

03/04 2017

2.x-dev

2.9999999.9999999.9999999-dev

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

11/01 2017

2.17.1

2.17.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

25/10 2016

2.17.0

2.17.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

31/08 2016

2.16.1

2.16.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

31/08 2016

2.16.0

2.16.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

19/08 2016

2.15.2

2.15.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

28/05 2016

2.15.1

2.15.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

22/05 2016

2.15.0

2.15.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

21/04 2016

2.14.0

2.14.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

26/11 2015

2.13.0

2.13.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

20/11 2015

2.12.2

2.12.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

20/11 2015

dev-preview

dev-preview

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

09/11 2015

2.12.1

2.12.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

15/08 2015

2.12.0

2.12.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

29/06 2015

2.11.0

2.11.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

23/06 2015

2.10.3

2.10.3.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

19/06 2015

2.10.2

2.10.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

09/05 2015

2.10.1

2.10.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

09/05 2015

2.10.0

2.10.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

28/04 2015

2.9.2

2.9.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

08/04 2015

2.9.1

2.9.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

31/03 2015

2.9.0

2.9.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

17/03 2015

2.8.2

2.8.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

16/03 2015

2.8.1

2.8.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

16/03 2015

2.8.0

2.8.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

08/02 2015

2.7.1

2.7.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

26/01 2015

2.7.0

2.7.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

10/12 2014

2.6.2

2.6.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

10/12 2014

2.6.1

2.6.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

04/12 2014

2.6.0

2.6.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

19/10 2014

2.5.0

2.5.0.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

12/09 2014

2.4.2

2.4.2.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

12/09 2014

2.4.1

2.4.1.0

Asset Bundle for Yii2 with Font Awesome

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

12/09 2014

2.4.0

2.4.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

MIT

The Requires

 

bundle yii asset font awesome

01/09 2014

2.3.0

2.3.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/08 2014

2.2.1

2.2.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/08 2014

2.2.0

2.2.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/08 2014

2.1.1

2.1.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/08 2014

2.1.0

2.1.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/06 2014

2.0.2

2.0.2.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL-3.0

The Requires

 

bundle yii asset font awesome

05/06 2014

2.0.1

2.0.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

05/06 2014

2.0.0

2.0.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

05/06 2014

1.2.1

1.2.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

05/06 2014

1.2.0

1.2.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

16/05 2014

1.1.2

1.1.2.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

11/05 2014

1.1.1

1.1.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

24/03 2014

1.1.0

1.1.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

27/02 2014

1.0.3

1.0.3.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

27/02 2014

1.0.2

1.0.2.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

27/02 2014

1.0.1

1.0.1.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome

27/02 2014

1.0.0

1.0.0.0

Font Awesome Asset Bundle for Yii2

  Sources   Download

GPL v3

The Requires

 

bundle yii asset font awesome