bugo/fa-php-helper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bugo/fa-php-helper

最新稳定版本:0.8

Composer 安装命令:

composer require bugo/fa-php-helper

包简介

Helper classes to get FontAwesome icons html code

README 文档

README

PHP Coverage

По-русски

Description

This package is designed to generate HTML code for FontAwesome 7 icons. The following features are available:

  • add icon colors
  • resize icons
  • support for both modern (fa-solid fa-) and deprecated (fas fa-) classes.
  • optionally add the aria-hidden="true" attribute to hide icons from screen readers, etc.
  • get CSS class of a random icon
  • collection of CSS classes of all icons

Installation

composer require bugo/fa-php-helper

Usage

If only CSS classes are needed:

<?php

use Bugo\FontAwesome\Enums\Icon;

// 'fa-solid fa-user'
echo Icon::V7->solid('user');

// 'fa-regular fa-user'
echo Icon::V7->regular('user');

// 'fa-brands fa-windows'
echo Icon::V7->brand('windows');

Advanced example:

<?php

use Bugo\FontAwesome\Enums\Icon;

$icon = Icon::V7->solid('user');

// '<i class="fa-solid fa-user fa-2xl" style="color:red" title="User" aria-hidden="true"></i>'
var_dump(
    $icon
        ->color('red')
        ->size('2xl')
        ->title('User')
        ->ariaHidden()
        ->html()
);

Additional classes can be passed through the addClass method:

<?php

use Bugo\FontAwesome\Enums\Icon;

$icon = Icon::V7->solid('heart');

// '<i class="fa-solid fa-heart fa-beat"></i>'
var_dump(
    $icon
        ->addClass('fa-beat')
        ->html()
);

You can also get a random icon:

<?php

use Bugo\FontAwesome\Enums\Icon;

var_dump(Icon::V7->random());

And so you can get the whole collection with all CSS classes at once:

<?php

use Bugo\FontAwesome\Enums\Icon;

var_dump(Icon::V7->collection());

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-05