This is achieved by replacing the icons with their svg counterpart before sending the response to the client.
- PHP >= 7.1.3
- Laravel >= 5.6
Install the package using Composer.
composer require jerodev/laravel-font-awesome
The package will be auto-discovered by Laravel. If you disabled auto-discovery, you should add the following provider to your
To use Font Awesome icons in your view there are a few new blade directives.
// Let the package discover the best library for this icon. @fa('laravel') // Define the library that should be used. @far('circle') // Regular @fas('circle') // Solid @fab('laravel') // Brands
When using the
@fa() directive. The package will scan the different Font Awesome libraries and use the first library where it finds the icon.
The order in which the libraries are scanned is
solid. But this can be modified in the configuration.
This package includes a middleware that injects a minimal stylesheet into your views on render. By default, this middleware is added to the
web middleware group.
If you don’t want to have the style injected automatically, you can disable
middleware.all_requests in the configuration. In this case, you will have to add the middleware to selected routes yourself or add your own CSS.
The middleware you should use is
The package contains a few configuration options that can be modified by first publishing the config file using the command below. This will create a
fontawesome.php file in your
php artisan vendor:publish --provider="Jerodev\LaraFontAwesome\FontAwesomeServviceProvider"
['regular', 'brands', 'solid']
|The icon libraries that will be available. This is also the order in which the libraries will be searched for icons.
|When enabled, the stylesheet needed for the icons will automatically be injected on every request returning html.
In the future however, I want to add these as well to make this package support the full api that is available using the Font Awesome library.