Download the PHP package jerodev/laravel-font-awesome without Composer
On this page you can find all versions of the php package jerodev/laravel-font-awesome. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jerodev/laravel-font-awesome
More information about jerodev/laravel-font-awesome
Files in jerodev/laravel-font-awesome
Package laravel-font-awesome
Short Description A Laravel package that renders Font Awesome icons server-side
License MIT
Homepage https://github.com/jerodev/laravel-font-awesome
Informations about the package laravel-font-awesome
:bangbang: This package is no longer maintained.
I recommend switching to https://github.com/blade-ui-kit/blade-icons
Font Awesome Blade directives for Laravel
This package will render font awesome icons in your views on the server side. This removes the need to add extra JavaScript or webfont resources on the client side and in doing so reduces the size of your website significantly.
This is achieved by replacing the icons with their svg counterpart before sending the response to the client.
Requirements
Requirement | Version |
---|---|
PHP | >= 7.2 |
Laravel | 6.x |
Laravel 5.x
For Laravel 5.6 and up, use version v1.x of this package
Installation
Install the package using Composer.
composer require jerodev/laravel-font-awesome
Service Provider
The package will be auto-discovered by Laravel. If you disabled auto-discovery, you should add the following provider to your config/app.php
file.
\Jerodev\LaraFontAwesome\FontAwesomeServiceProvider::class,
Usage
Middleware
:warning: Since version 2.0, the middleware is no longer automatically injected. You will have to add this to the routes where needed.
This package includes a middleware, InjectStyleSheet
, that injects a minimal stylesheet into your views on render.
The middleware can be added to your routes as documented by Laravel:
Views
To use Font Awesome icons in your view there are a few new blade directives.
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 regular
, brands
, solid
. But this can be modified in the configuration.
Parameters
The @fa()
function can take three parameters of which only the first is required.
Parameter | Type | Description |
---|---|---|
name |
string | The name of the icon |
css_class |
string | Extra css classes to be appended to the svg output |
force_svg_href |
bool | Force the output to be an svg href link if possible. Can be useful in loops. |
Configuration
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 config
folder.
php artisan vendor:publish --provider="Jerodev\LaraFontAwesome\FontAwesomeServiceProvider"
Key | Type | Default value | Description |
---|---|---|---|
libraries |
string[] | ['regular', 'brands', 'solid'] |
The icon libraries that will be available. This is also the order in which the libraries will be searched for icons. |
svg_href |
bool | true |
Use svg href links for consecutive icons. |