├── .gitignore ├── .scrutinizer.yml ├── .travis.yml ├── AssetBundle.php ├── CHANGELOG.md ├── CdnFreeAssetBundle.php ├── CdnProAssetBundle.php ├── FA.php ├── FAB.php ├── FAL.php ├── FAR.php ├── FAS.php ├── FontAwesome.php ├── LICENSE ├── NpmFreeAssetBundle.php ├── NpmProAssetBundle.php ├── README.md ├── bin ├── .gitignore └── convertNames.sh ├── cdn └── AssetBundle.php ├── component ├── Icon.php ├── Stack.php └── UnorderedList.php ├── composer.json ├── composer.lock ├── phpunit.xml.dist └── tests └── unit ├── .gitignore ├── TestCase.php ├── bootstrap.php ├── config ├── .gitignore └── main.php ├── fontawesome └── MainTest.php └── runtime ├── .gitignore └── assets └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | /coverage 4 | /node_modules 5 | /package.json 6 | /package.lock 7 | /yarn.lock 8 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | build: 2 | environment: 3 | php: 4 | version: 7.1 5 | dependencies: 6 | before: 7 | - composer global require "fxp/composer-asset-plugin:~1.1" 8 | tests: 9 | override: 10 | - phpunit 11 | imports: 12 | - php 13 | checks: 14 | php: 15 | code_rating: true 16 | duplication: true 17 | tools: 18 | php_sim: false 19 | php_cpd: false 20 | php_pdepend: true 21 | php_analyzer: true 22 | php_changetracking: true 23 | external_code_coverage: 24 | timeout: 2100 # Timeout in seconds. 25 | filter: 26 | excluded_paths: 27 | - tests/* 28 | - vendor/* 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | 3 | language: php 4 | 5 | php: 6 | - 7.1 7 | - 7.2 8 | - 7.3 9 | 10 | matrix: 11 | fast_finish: true 12 | 13 | sudo: false 14 | 15 | cache: 16 | directories: 17 | - vendor 18 | 19 | install: 20 | - travis_retry composer self-update && composer --version 21 | - travis_retry composer global require "fxp/composer-asset-plugin:~1.1" 22 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 23 | - travis_retry composer install --prefer-dist --no-interaction 24 | 25 | script: 26 | - ./vendor/bin/phpunit --verbose --coverage-clover=coverage/coverage.clover 27 | 28 | after_script: 29 | - travis_retry wget https://scrutinizer-ci.com/ocular.phar 30 | - php ocular.phar code-coverage:upload --format=php-clover coverage/coverage.clover 31 | -------------------------------------------------------------------------------- /AssetBundle.php: -------------------------------------------------------------------------------- 1 | fixed_width()` is deprecated. Use instead `icon()->fixedWidth()`. 171 | * Method `icon()->pull_left()` is deprecated. Use instead `icon()->pullLeft()`. 172 | * Method `icon()->pull_right()` is deprecated. Use instead `icon()->pullRight()`. 173 | * Updated tests. 174 | 175 | 2015-04-08 - 2.9.1 176 | ------------------ 177 | * Fix asset bundle publish bug on windows. 178 | 179 | 2015-03-31 - 2.9.0 180 | ------------------ 181 | * In asset bundle added `init` method for filtering publising assets. 182 | 183 | 2015-03-17 - 2.8.2 184 | ------------------ 185 | * Refactoring. 186 | 187 | 2015-03-16 - 2.8.1 188 | ------------------ 189 | * Update readme. 190 | 191 | 2015-03-16 - 2.8.0 192 | ------------------ 193 | * In class `FA` add static property `cssPrefix` for customizing css class. 194 | * Refactoring. 195 | * Update readme. 196 | 197 | 2015-02-08 - 2.7.1 198 | ------------------ 199 | * Update travisCI config. 200 | 201 | 2015-01-26 - 2.7.0 202 | ------------------ 203 | * `Font Awesome` updated to version `4.3`. 204 | * Update icons constants list. 205 | * Update readme. 206 | 207 | Until 2015-03-04 208 | ---------------- 209 | * Implementation of extension. 210 | -------------------------------------------------------------------------------- /CdnFreeAssetBundle.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'css/*', 25 | 'js/*', 26 | 'webfonts/*', 27 | 'sprites/*', 28 | 'svgs/*', 29 | ], 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /NpmProAssetBundle.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'css/*', 25 | 'js/*', 26 | 'webfonts/*', 27 | 'sprites/*', 28 | 'svgs/*', 29 | ], 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Yii 2 [Font Awesome](http://fortawesome.github.io/Font-Awesome/) Asset Bundle 2 | =============================== 3 | 4 | This extension provides a assets bundle with [Font Awesome](https://fontawesome.com/) 5 | for [Yii framework 2.0](http://www.yiiframework.com/) applications and helper to use icons. 6 | 7 | For license information check the [LICENSE](https://github.com/rmrevin/yii2-fontawesome/blob/master/LICENSE)-file. 8 | 9 | [![License](https://poser.pugx.org/rmrevin/yii2-fontawesome/license.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 10 | [![Latest Stable Version](https://poser.pugx.org/rmrevin/yii2-fontawesome/v/stable.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 11 | [![Latest Unstable Version](https://poser.pugx.org/rmrevin/yii2-fontawesome/v/unstable.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 12 | [![Total Downloads](https://poser.pugx.org/rmrevin/yii2-fontawesome/downloads.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 13 | 14 | Code Status 15 | ----------- 16 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master) 17 | [![Code Coverage](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master) 18 | [![Travis CI Build Status](https://travis-ci.org/rmrevin/yii2-fontawesome.svg)](https://travis-ci.org/rmrevin/yii2-fontawesome) 19 | [![Dependency Status](https://www.versioneye.com/user/projects/54119b799e16229fe00000da/badge.svg)](https://www.versioneye.com/user/projects/54119b799e16229fe00000da) 20 | 21 | Support 22 | ------- 23 | * [GutHub issues](https://github.com/rmrevin/yii2-fontawesome/issues) 24 | * [Public chat](https://gitter.im/rmrevin/support) 25 | 26 | Fontawesome version 27 | ------------------- 28 | | Version of font-awesome | Version of extension | 29 | | ---:|:--- | 30 | | 4.* | ~2.17 | 31 | | 5.* | ~3.0 | 32 | 33 | Update to `3.2` 34 | --------------- 35 | 36 | Be careful in version 3.2 `rmrevin\yii\fontawesome\AssetBundle` package use cdn by default. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md). 37 | 38 | Update to `3.0` 39 | --------------- 40 | 41 | Be careful in version 3.0 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md). 42 | 43 | Update to `2.17` 44 | ---------------- 45 | 46 | Be careful in version 2.17 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/2.x/CHANGELOG.md). 47 | 48 | Installation 49 | ------------ 50 | 51 | The preferred way to install this extension is through [composer](https://getcomposer.org/). 52 | 53 | Either run 54 | 55 | ```bash 56 | composer require "rmrevin/yii2-fontawesome:~3.5" 57 | ``` 58 | 59 | or add 60 | 61 | ``` 62 | "rmrevin/yii2-fontawesome": "~3.5", 63 | ``` 64 | 65 | to the `require` section of your `composer.json` file. 66 | 67 | Usage with fa pro version 68 | ------------------------- 69 | 70 | ### CDN 71 | Register your domain here - https://fontawesome.com/how-to-use/on-the-web/setup/getting-started 72 | 73 | Add `CdnProAssetBundle` as depends of your app asset bundle: 74 | ```php 75 | class AppAsset extends AssetBundle 76 | { 77 | // ... 78 | 79 | public $depends = [ 80 | // ... 81 | 'rmrevin\yii\fontawesome\CdnProAssetBundle' 82 | ]; 83 | } 84 | 85 | ``` 86 | 87 | Or inject `CdnProAssetBundle` in your view: 88 | 89 | ```php 90 | \rmrevin\yii\fontawesome\CdnProAssetBundle::register($this); 91 | ``` 92 | 93 | ### NPM 94 | Install npm package of font: 95 | ``` 96 | npm install @fortawesome/fontawesome-pro 97 | ``` 98 | or 99 | ``` 100 | yarn add @fortawesome/fontawesome-pro 101 | ``` 102 | 103 | And add `NpmProAssetBundle` as depends of your app asset bundle: 104 | ```php 105 | class AppAsset extends AssetBundle 106 | { 107 | // ... 108 | 109 | public $depends = [ 110 | // ... 111 | 'rmrevin\yii\fontawesome\NpmProAssetBundle' 112 | ]; 113 | } 114 | 115 | ``` 116 | 117 | Or inject `NpmProAssetBundle` in your view: 118 | 119 | ```php 120 | rmrevin\yii\fontawesome\NpmProAssetBundle::register($this); 121 | ``` 122 | 123 | ### Optional 124 | 125 | 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`. 126 | 127 | ``` 128 | "replace": { 129 | "fortawesome/font-awesome": "*" 130 | }, 131 | ``` 132 | 133 | Usage with fa free version 134 | ------------------------- 135 | 136 | ### CDN 137 | Add `CdnFreeAssetBundle` as depends of your app asset bundle: 138 | ```php 139 | class AppAsset extends AssetBundle 140 | { 141 | // ... 142 | 143 | public $depends = [ 144 | // ... 145 | 'rmrevin\yii\fontawesome\CdnFreeAssetBundle' 146 | ]; 147 | } 148 | 149 | ``` 150 | 151 | Or inject `CdnFreeAssetBundle` in your view: 152 | 153 | ```php 154 | rmrevin\yii\fontawesome\CdnFreeAssetBundle::register($this); 155 | ``` 156 | 157 | # Composer 158 | 159 | Free version of package `fortawesome/font-awesome` already installed in vendor. 160 | 161 | Add `NpmFreeAssetBundle` as depends of your app asset bundle: 162 | ```php 163 | class AppAsset extends AssetBundle 164 | { 165 | // ... 166 | 167 | public $depends = [ 168 | // ... 169 | 'rmrevin\yii\fontawesome\NpmFreeAssetBundle' 170 | ]; 171 | } 172 | 173 | ``` 174 | 175 | Or inject `NpmFreeAssetBundle` in your view: 176 | 177 | ```php 178 | rmrevin\yii\fontawesome\NpmFreeAssetBundle::register($this); 179 | ``` 180 | 181 | Class reference 182 | --------------- 183 | 184 | Namespace: `rmrevin\yii\fontawesome`; 185 | 186 | ### Class `FAB`, `FAL`, `FAR`, `FAS` or `FontAwesome` 187 | 188 | * `static FAR::icon($name, $options=[])` - Creates an [`component\Icon`](#class-componenticon) that can be used to FontAwesome html icon 189 | * `$name` - name of icon in font awesome set. 190 | * `$options` - additional attributes for `i.fa` html tag. 191 | * `static FAR::stack($name, $options=[])` - Creates an [`component\Stack`](#class-componentstack) that can be used to FontAwesome html icon 192 | * `$options` - additional attributes for `span.fa-stack` html tag. 193 | 194 | ### Class `component\Icon` 195 | 196 | * `(string)$Icon` - render icon 197 | * `$Icon->addCssClass($value)` - add to html tag css class in `$value` 198 | * `$value` - name of css class 199 | * `$Icon->inverse()` - add to html tag css class `fa-inverse` 200 | * `$Icon->spin()` - add to html tag css class `fa-spin` 201 | * `$Icon->fixedWidth()` - add to html tag css class `fa-fw` 202 | * `$Icon->ul()` - add to html tag css class `fa-ul` 203 | * `$Icon->li()` - add to html tag css class `fa-li` 204 | * `$Icon->border()` - add to html tag css class `fa-border` 205 | * `$Icon->pullLeft()` - add to html tag css class `pull-left` 206 | * `$Icon->pullRight()` - add to html tag css class `pull-right` 207 | * `$Icon->size($value)` - add to html tag css class with size 208 | * `$value` - size value (variants: `FA::SIZE_LARGE`, `FA::SIZE_2X`, `FA::SIZE_3X`, `FA::SIZE_4X`, `FA::SIZE_5X`) 209 | * `$Icon->rotate($value)` - add to html tag css class with rotate 210 | * `$value` - rotate value (variants: `FA::ROTATE_90`, `FA::ROTATE_180`, `FA::ROTATE_270`) 211 | * `$Icon->flip($value)` - add to html tag css class with rotate 212 | * `$value` - flip value (variants: `FA::FLIP_HORIZONTAL`, `FA::FLIP_VERTICAL`) 213 | 214 | ### Class `component\Stack` 215 | 216 | * `(string)$Stack` - render icon stack 217 | * `$Stack->icon($icon, $options=[])` - set icon for stack 218 | * `$icon` - name of icon or `component\Icon` object 219 | * `$options` - additional attributes for icon html tag. 220 | * `$Stack->icon($icon, $options=[])` - set background icon for stack 221 | * `$icon` - name of icon or `component\Icon` object 222 | * `$options` - additional attributes for icon html tag. 223 | 224 | Helper examples 225 | --------------- 226 | 227 | ```php 228 | use rmrevin\yii\fontawesome\FAS; 229 | // or (only in pro version https://fontawesome.com/pro) 230 | // use rmrevin\yii\fontawesome\FAR; 231 | // use rmrevin\yii\fontawesome\FAL; 232 | // use rmrevin\yii\fontawesome\FAB; 233 | 234 | // normal use 235 | echo FAS::icon('home'); // 236 | 237 | // shortcut 238 | echo FAS::i('home'); // 239 | 240 | // icon with additional attributes 241 | echo FAS::icon( 242 | 'arrow-left', 243 | ['class' => 'big', 'data-role' => 'arrow'] 244 | ); // 245 | 246 | // icon in button 247 | echo Html::submitButton( 248 | Yii::t('app', '{icon} Save', ['icon' => FAS::icon('check')]) 249 | ); // 250 | 251 | // icon with additional methods 252 | echo FAS::icon('cog')->inverse(); // 253 | echo FAS::icon('cog')->spin(); // 254 | echo FAS::icon('cog')->fixedWidth(); // 255 | echo FAS::icon('cog')->li(); // 256 | echo FAS::icon('cog')->border(); // 257 | echo FAS::icon('cog')->pullLeft(); // 258 | echo FAS::icon('cog')->pullRight(); // 259 | 260 | // icon size 261 | echo FAS::icon('cog')->size(FAS::SIZE_3X); 262 | // values: FAS::SIZE_LARGE, FAS::SIZE_2X, FAS::SIZE_3X, FAS::SIZE_4X, FAS::SIZE_5X 263 | // 264 | 265 | // icon rotate 266 | echo FAS::icon('cog')->rotate(FAS::ROTATE_90); 267 | // values: FAS::ROTATE_90, FAS::ROTATE_180, FAS::ROTATE_180 268 | // 269 | 270 | // icon flip 271 | echo FAS::icon('cog')->flip(FAS::FLIP_VERTICAL); 272 | // values: FAS::FLIP_HORIZONTAL, FAS::FLIP_VERTICAL 273 | // 274 | 275 | // icon with multiple methods 276 | echo FAS::icon('cog') 277 | ->spin() 278 | ->fixedWidth() 279 | ->pullLeft() 280 | ->size(FAS::SIZE_LARGE); 281 | // 282 | 283 | // icons stack 284 | echo FAS::stack() 285 | ->icon('twitter') 286 | ->on('square-o'); 287 | // 288 | // 289 | // 290 | // 291 | 292 | // icons stack with additional attributes 293 | echo FAS::stack(['data-role' => 'stacked-icon']) 294 | ->on(FAS::Icon('square')->inverse()) 295 | ->icon(FAS::Icon('cog')->spin()); 296 | // 297 | // 298 | // 299 | // 300 | 301 | // Stacking text and icons 302 | echo FAS::stack() 303 | ->on(FAS::Icon('square')) 304 | ->text('1'); 305 | // 306 | // 307 | // 1 308 | // 309 | 310 | // Stacking text and icons with options 311 | echo FAS::stack() 312 | ->on(FAS::Icon('square')) 313 | ->text('1', ['tag'=>'strong', 'class'=>'stacked-text']); 314 | // 315 | // 316 | // 1 317 | // 318 | // Now you can add some css for vertical text positioning: 319 | .stacked-text { margin-top: .3em; } 320 | 321 | // unordered list icons 322 | echo FAS::ul(['data-role' => 'unordered-list']) 323 | ->item('Bullet item', ['icon' => 'circle']) 324 | ->item('Checked item', ['icon' => 'check']); 325 | //