Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dragomano/fa-php-helper
Helper classes to get FontAwesome icons html code
https://github.com/dragomano/fa-php-helper
fontawesome fontawesome6 php
Last synced: 5 days ago
JSON representation
Helper classes to get FontAwesome icons html code
- Host: GitHub
- URL: https://github.com/dragomano/fa-php-helper
- Owner: dragomano
- License: mit
- Created: 2024-03-05T15:34:26.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T16:21:11.000Z (8 months ago)
- Last Synced: 2024-05-22T17:35:06.161Z (8 months ago)
- Topics: fontawesome, fontawesome6, php
- Language: PHP
- Homepage:
- Size: 86.9 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FontAwesome PHP Helper
![PHP](https://img.shields.io/badge/PHP-^8.1-blue.svg?style=flat)
![Coverage](https://badgen.net/coveralls/c/github/dragomano/fa-php-helper/main)[По-русски](README.ru.md)
## Description
This package is designed to generate CSS classes and HTML code for FontAwesome 6 icons. In addition, the following features are available:
- add icon colors
- resize icons
- support for both modern (`fa-solid fa-`) and deprecated (`fas fa-`) classes.
- use fixed width icons (`fa-fw`) to display in lists
- 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
```bash
composer require bugo/fa-php-helper
```## Using
If only CSS classes are needed:
```php
solid('user');// 'fa-regular fa-user'
echo Icon::V6->regular('user');// 'fa-brands fa-windows'
echo Icon::V6->brand('windows');
```Advanced example:
```php
brand('windows');// 'fab fa-windows fa-fw text-red-500'
var_dump(
$icon
->fixedWidth()
->color('text-red-500')
->text()
);$icon = Icon::V6->solid('user');
// ''
var_dump(
$icon
->color('red')
->size('2xl')
->title('User')
->ariaHidden()
->html()
);
```Additional classes can be passed through the `addClass` method:
```php
solid('heart');// ''
var_dump(
$icon
->addClass('fa-beat')
->html()
);
```You can also get a random icon:
```php
random());
```And so you can get the whole collection with all CSS classes at once:
```php
collection());
```