PHPackages                             roelmagdaleno/php-heroicons - 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. roelmagdaleno/php-heroicons

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

roelmagdaleno/php-heroicons
===========================

A package to easily use Heroicons in PHP projects.

1.1.0(1y ago)69192MITPHPPHP ^8.0

Since Jul 28Pushed 1y ago2 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

PHP Heroicons
=============

[](#php-heroicons)

A package to render [Heroicons](https://github.com/tailwindlabs/heroicons) in your PHP application.

Preview the icons at [heroicons.com](https://heroicons.com), developed by [Steve Schoger](https://twitter.com/steveschoger) and [Adam Wathan](https://twitter.com/adamwathan).

If you want to render Heroicons in your Laravel Blade views, use [Blade Heroicons](https://github.com/blade-ui-kit/blade-heroicons) package.

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

[](#installation)

### Composer

[](#composer)

```
composer require roelmagdaleno/php-heroicons
```

Usage
-----

[](#usage)

You can render a Heroicon using multiple ways:

### Helper

[](#helper)

Return the SVG by using the `heroicon()` helper function:

```
$text = heroicon('check-circle', ['width' => 60]);
echo "My icon is: $text";
```

Print the SVG directly:

```
echo heroicon('check-circle', ['width' => 60]);
```

### Constructor

[](#constructor)

Instantiate an `Icon` class with parameters and print it directly:

```
use PHPHeroIcons\Icon;

echo new Icon('check-circle', ['width' => 60]);
```

Instantiate an `Icon` class with parameters and call the `render()` method.

```
use PHPHeroIcons\Icon;

$icon = new Icon('academic-cap', ['width' => 60]);
$icon->render();
```

Instantiate an `Icon` class with parameters and call the `return()` method.

```
use PHPHeroIcons\Icon;

$icon = new Icon('academic-cap', ['width' => 60]);
$text = $icon->return();

echo "My icon is: $text";
```

### Render Method

[](#render-method)

If you want to render multiples icons and only use one `Icon` instance:

```
use PHPHeroIcons\Icon;

$icon = new Icon();

$icon->render('check-circle', ['width' => 60]);
$icon->render('academic-cap', ['width' => 60]);
$icon->render('library', ['width' => 60]);
```

### Return Method

[](#return-method)

If you want to return multiples icons and only use one `Icon` instance:

```
use PHPHeroIcons\Icon;

$icon = new Icon();

$first  = $icon->return('check-circle', ['width' => 60]);
$second = $icon->return('academic-cap', ['width' => 60]);
$third  = $icon->return('library', ['width' => 60]);

echo "My first icon is: $first then use the $second and $third";
```

Parameters
----------

[](#parameters)

The `Icon` constructor, `heroicon()`, `render()` and `return()` methods accepts these attributes in this order:

- $icon
- $attributes
- $type

Example:

```
heroicon($icon, $attributes, $type);
```

The `$icon` accepts any [Heroicon](https://heroicons.com) slug and if you insert an icon that doesn't exist it won't return anything.

For `$attributes` (optional) you can pass only these attributes as array key/value format:

- `width`
- `height`
- `class`
- `id`

If you pass an attribute that is not listed previously it won't be attached to the SVG HTML.

And last, but not least, you can specify the Heroicon `$type`:

- `solid`
- `outline`

By default the icons will be printed in `solid` type.

Example:

```
heroicon(
    'library',
    [
        'width'  => 60,
        'height' => 60,
        'class'  => 'my-custom-css-class',
        'id'     => 'my-custom-id',
    ]
); // Print solid icon with multiple attributes.

heroicon(
    'check-circle',
    [
        'width'  => 60,
        'height' => 60,
        'class'  => 'my-custom-css-class',
        'id'     => 'my-custom-id',
    ],
    'outline'
); // Print outline icon with multiple attributes.
```

Examples
--------

[](#examples)

For more usage examples visit the `examples/index.php` file or visit the [PHPSandbox.io](https://phpsandbox.io/e/x/8qt7v?layout=EditorPreview&iframeId=z2x1jnoxen&theme=dark&defaultPath=%2F&showExplorer=no#index.php) to play with the code.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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

Every ~617 days

Total

3

Last Release

521d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.0.1PHP &gt;=7.2

1.1.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b2f8632cbecc6f9a25cddf3861bb17d54c1d228502bb30e9f60020a1dfd76f7?d=identicon)[roelmagdaleno](/maintainers/roelmagdaleno)

---

Top Contributors

[![roelmagdaleno](https://avatars.githubusercontent.com/u/3928004?v=4)](https://github.com/roelmagdaleno "roelmagdaleno (8 commits)")[![nicko170](https://avatars.githubusercontent.com/u/9477420?v=4)](https://github.com/nicko170 "nicko170 (1 commits)")

---

Tags

heroiconsphpphpiconsHeroicons

### Embed Badge

![Health badge](/badges/roelmagdaleno-php-heroicons/health.svg)

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

###  Alternatives

[tomatophp/filament-icons

Picker &amp; Table Column &amp; Icons Provider for FilamentPHP

3598.2k13](/packages/tomatophp-filament-icons)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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