PHPackages                             xicrow/php-icons - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xicrow/php-icons

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xicrow/php-icons
================

Icon management through PHP

1.0.0(3y ago)06MITPHPPHP ^7.4

Since Sep 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/xicrow/php-icons)[ Packagist](https://packagist.org/packages/xicrow/php-icons)[ RSS](/packages/xicrow-php-icons/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Icons
=========

[](#php-icons)

Installation
------------

[](#installation)

The recommended way to install is through Composer.

```
composer require xicrow/php-icons

```

Usage
-----

[](#usage)

Depending on what icons you are using (or want to use), implement the icon class of your choice:

```
// FontAwesome 4
echo \Xicrow\PhpIcons\FontAwesome4::Icon(\Xicrow\PhpIcons\FontAwesome4::Icon_Thumbs_Up);
```

```

```

```
// FontAwesome 5
echo \Xicrow\PhpIcons\FontAwesome5::Icon(\Xicrow\PhpIcons\FontAwesome5::Icon_Thumbs_Up);
```

```

```

For now, we'll just use the `BaseIcon` class, to show usages.

Basic usage, show an icon:

```
echo BaseIcon::Icon(ICON_IDENTIFIER);
```

```

```

Apply one or more modifiers (not all icon packs support modifiers):

```
echo BaseIcon::Icon(ICON_IDENTIFIER, ICON_MODIFIER, ICON_MODIFIER);
```

```

```

Modifiers can also be chained from the icon:

```
echo BaseIcon::Icon(ICON_IDENTIFIER)
    ->modify(ICON_MODIFIER)
    ->modify(ICON_MODIFIER)
;
```

```

```

Attributes for the icon can also be set by chaining:

```
echo BaseIcon::Icon(ICON_IDENTIFIER)
    ->modify(ICON_MODIFIER)
    ->modify(ICON_MODIFIER)
    ->attribute('title', 'Nifty help text')
    ->attribute('style', 'color: blue;')
;
```

```

```

Untill the icon is rendered (either through the `BaseIcon::render()` method or other to-string triggers like `echo`), it is possible to add modifiers and attributes to the icon.

```
// Made-up constants
$oStatusIcon = BaseIcon::Icon(BaseIcon::Icon_Bullet, BaseIcon::Modifier_Size_X2);
// Looping a resultset
foreach ($arrResults as $oResult) {
    // Clone the status icon, set color from result, and render
    echo (clone $oStatusIcon)->attribute('style', 'color: '.$oResult->strStatusColor.';');
}
```

Extending
---------

[](#extending)

Instead of using the classes in this repository directly, you are encouraged to implement your own extension like so:

```
class FA extends \Xicrow\PhpIcons\FontAwesome5 {}

echo FA::Icon(FA::Icon_Thumbs_Up, FA::Modifier_Lg);
```

This will ease your own implementation, since you determine what the class will be called and also makes it easier for you to change provider in the future.

It also makes it easy to implement shortcuts for commonly used icons:

```
class FA extends \Xicrow\PhpIcons\FontAwesome5 {
    public static function IconCreate(): self
    {
        return static::Icon(static::Icon_Plus_Circle)->attribute('style', 'color: green;');
    }

    public static function IconEdit(): self
    {
        return static::Icon(static::Icon_Pencil)->attribute('style', 'color: blue;');
    }

    public static function IconDelete(): self
    {
        return static::Icon(static::Icon_Trash)->attribute('style', 'color: red;');
    }
}

echo FA::IconCreate();
```

Supported icon packs
--------------------

[](#supported-icon-packs)

Currently, there are generators and classes for the following icon packs:

- Bootstrap 3 Glyphicons
- Devicons
- FontAwesome 4
- FontAwesome 5 (free)

> Generators are used to create the constants for icons (and modifiers) for each icon pack, these generators will mostly be able to generate constants for every specific version of the icon pack, thereby supporting exactly the version you are using.
>
> Classes are simply the implementation of the specific icon pack, that is using the generated icon (and modifier) constants, and implementing a render method specific for that icon pack.

TODO
----

[](#todo)

- Maby generate Interfaces for all versions of icon packs ?
    - Will this clutter too much ?..
    - If done, they should be within their own separate namespace
        - `src/FontAwesome4/FontAwesome4_0_0Icons` (or something like that)
- Figure out if it's possible to get a list of FontAwesome 5 PRO icons
    - Their public accessible list of icons is, of course, only the free icons
- Ideas for new icon generators/classes:
    - Glyphicons
        -
    - IcoMoon
        -
        -
    - Ionicons
        -
        -
    - Material
        -
    - Icofont
        -
    - Icons8
        -
        -
        -
    - Typicons
        -
        -
    - Microns
        -
        -

License
-------

[](#license)

Copyright © 2022 Jan Ebsen Licensed under the MIT license.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1340d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f694b3f869e1e552f42f8842040bc765d08f4fc6ccd3bcd8d96bf04909008c23?d=identicon)[xicrow](/maintainers/xicrow)

---

Top Contributors

[![xicrow](https://avatars.githubusercontent.com/u/1567795?v=4)](https://github.com/xicrow "xicrow (15 commits)")

### Embed Badge

![Health badge](/badges/xicrow-php-icons/health.svg)

```
[![Health](https://phpackages.com/badges/xicrow-php-icons/health.svg)](https://phpackages.com/packages/xicrow-php-icons)
```

###  Alternatives

[mastergalen/adsense-ads

Display Adsense ads easily in Laravel.

1211.2k](/packages/mastergalen-adsense-ads)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
