awps/font-awesome-php
A lightweight PHP library for adding Font Awesome icons to any PHP or Laravel project. Render icons through a simple, fluent API with support for SVG and web fonts, sizes, and custom styling—no manual markup required.
composer require awps/font-awesome-php
vendor/awps/font-awesome-php/src. Confirm the namespace (typically Awps\FontAwesome) and the exact helper method names before writing wrappers.<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
use Awps\FontAwesome;
echo FontAwesome::icon('home');
// <i class="fa fa-home"></i>
<i class="fa fa-..."> markup, replace it with the helper, and verify the CSS version matches. Then roll the helper out across navigation, buttons, and status indicators.Blade directive or component wrapper. Keep the vendor call out of templates:
// app/Support/Icon.php
namespace App\Support;
use Awps\FontAwesome;
class Icon
{
public static function render(string $name, array $options = []): string
{
return FontAwesome::icon($name, $options);
}
}
{!! \App\Support\Icon::render('user', ['fixed' => true]) !!}
Option-array wrapper for common variants. Normalize the library's option keys once so call sites stay readable:
Icon::render('spinner', ['spin' => true, 'size' => 'lg']);
Icon::render('chevron-left', ['fixed' => true]);
Icon allowlist constants. Font Awesome 4.7 has hundreds of names and the library will happily emit a class for a typo that renders as nothing. Generate constants or an enum from the 4.7 variables.less icon list and validate names before rendering:
$name = in_array($requested, IconNames::ALL, true) ? $requested : 'question-circle';
Buttons and links. Compose the icon with visible text rather than shipping icon-only controls:
<a href="/users" class="btn btn-primary">
{!! Icon::render('users') !!} Manage users
</a>
Stacked/composite icons. For badges and overlays, use the package's stacking support if present (e.g. a stack() helper). If the package only exposes flat icons, compose the fa-stack markup in a dedicated Blade partial instead of scattering it.
Accessibility by default. Decorative icons should be hidden from assistive tech; meaningful icons need a label. Bake this into your wrapper:
return str_replace('<i ', '<i aria-hidden="true" ', FontAwesome::icon($name, $options));
Then pair icon-only controls with an sr-only text span.
Testing. Assert on the generated string. A small unit test around your Icon wrapper protects you from a future package swap:
$this->assertSame('<i class="fa fa-home"></i>', Icon::render('home'));
Integration tip. Because usage is static, you generally do not need a service provider or facade. If you prefer dependency injection for testability, bind your own IconRenderer class that delegates to the vendor library, and inject that instead.
fa fa-*, not fa-solid fa-*. Do not mix it with Font Awesome 5/6 CSS or markup; icons will silently fail to render. 4.7 is end-of-life and no longer receives icon updates.{!! !!}. Never pass user-controlled icon names straight through; validate against an allowlist to avoid markup injection and broken output.each()-era code) before adopting, and consider vendoring or forking the single class if you only need one method. MIT license makes this straightforward.use statements unless the README says otherwise.var_dump the exact returned string and compare it character-for-character with a known-good <i class="fa fa-home"></i>. Most issues are a missing fa base class, a wrong CSS version, or an option key the library quietly ignores.How can I help you explore Laravel packages today?