kartik-v/yii2-icons
Composer 安装命令:
composer require kartik-v/yii2-icons
包简介
Set of icon frameworks for use in Yii Framework 2.0
关键字:
README 文档
README
yii2-icons
This extension offers an easy method to setup various icon frameworks to work with Yii Framework 2.0. Most popular and free icon frameworks available are currently supported. This list may be extended in future based on demand and feedback.
- Bootstrap Glyphicons
- Font Awesome
- Unicode Icons: A collection of unicode symbols made available as CSS icons by Krajee
- Elusive Icons
- Typicons
- Web Hosting Hub Glyphs
- JQuery UI Icons
- Socicon Icons: Needs you to add attribution to the icon source.
- Octicons: The Github icons collection.
- Flag-Icons
- Open Iconic Icons
- IcoFont Icons
Demo
You can see a demonstration here and API Code Documentation on usage of this extension with documentation and examples.
Installation
The preferred way to install this extension is through composer.
Note: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the
minimum-stabilitysettings for your application's composer.json.
Either run
$ php composer.phar require kartik-v/yii2-icons "@dev"
or add
"kartik-v/yii2-icons": "@dev"
to the require section of your composer.json file.
Usage
Global Setup
In case you wish to setup one Icon framework globally, set the parameter icon-framework in the params array of your Yii Configuration File.
'params' => [ 'icon-framework' => \kartik\icons\Icon::FAS, // Font Awesome Icon framework ]
To initialize the globally setup framework in your view, call this code in your view or view layout file.
use kartik\icons\Icon; Icon::map($this);
Per View Setup
You can also call each icon-framework individually in your view or view layout like below. Map any icon framework within each view as in the example below.
use kartik\icons\Icon; Icon::map($this, Icon::EL); // Maps the Elusive icon font framework
Displaying Icons
After mapping your icon framework with one of the options above, you can display icons using Icon::show method. Icons can be displayed using one of the options below:
use kartik\icons\Icon; // Option 1: Uses the `icon-framework` setup in Yii config params. echo Icon::show('user'); // Option 2: Specific Icon Call in a view. Additional options can also be passed to style the icon. echo Icon::show('user', ['class'=>'fa-2x', 'framework' => Icon::FAS]);
NOTE: The
kartik\icons\Icon::showmethod outputs a HTML formatted text. So in order to display icons in Yii-2 components like Navbar or Nav, you must setencodeLabelsto false.
$items = [ ['label' => Icon::show('home') . 'Home', 'url' => ['/site/index']], ]; // Your other code /* Note you must encodeLabels to false to display icons in labels */ echo \kartik\nav\NavX::widget([ 'items' => $items, 'encodeLabels' => false ]); // Your other code
Displaying Stacked Icons
You can also display stacked icons for frameworks like Font Awesome, where this is supported. For example:
use kartik\icons\Icon; // fa-twitter on fa-square Icon::showStack('twitter', 'square', ['class'=>'fa-lg'], ['framework' => Icon::FAB], ['framework' => Icon::FAR]) // fa-flag on fa-circle Icon::showStack('flag', 'circle', ['class'=>'fa-lg'], ['class'=>'fa-inverse']);
Add Custom Icons
You can add custom icon sets to the list of available frameworks.
use kartik\icons\Icon; // add framework Icon::addFramework('custom', [ 'class' => '\common\icons\CustomIconAsset', 'prefix' => 'custom-icon', ]); // map to view file Icon::map($this, 'custom'); // show the icon echo Icon::show('menu',['framework' => 'custom']);
namespace common\icons; class CustomIconAsset extends \yii\web\AssetBundle { public $sourcePath = '@common/icons/assets/custom'; public $depends = array( 'yii\web\YiiAsset', 'yii\bootstrap4\BootstrapAsset' ); public $css=[ 'css/animation.css', 'css/custom-codes.css', 'css/custom-embedded.css', 'css/custom-ie7.css', 'css/custom-ie7-codes.css', 'css/custom.css', ]; }
The above asset bundle uses files genereted by http://fontello.com/.
License
yii2-icons is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.
kartik-v/yii2-icons 适用场景与选型建议
kartik-v/yii2-icons 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 1.02M 次下载、GitHub Stars 达 69, 最近一次更新时间为 2013 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「font」 「yii」 「icon」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kartik-v/yii2-icons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kartik-v/yii2-icons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kartik-v/yii2-icons 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
FontAwesome5 for Magento2
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
PHP SVG font parser
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 1.02M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 73
- 点击次数: 28
- 依赖项目数: 63
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-12-07