Download the PHP package hebinet/laravel-svg-icons without Composer
On this page you can find all versions of the php package hebinet/laravel-svg-icons. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hebinet/laravel-svg-icons
More information about hebinet/laravel-svg-icons
Files in hebinet/laravel-svg-icons
Package laravel-svg-icons
Short Description Allows to inline svg icons via a simple blade directive
License MIT
Homepage https://github.com/hebinet/laravel-svg-icons
Informations about the package laravel-svg-icons
Laravel SVG Icons
Allows to inline Font Awesome 5+'s SVG icons without javascript via a simple Laravel Blade directive.
Installation
Install composer package
You can install it using Composer:
Optionally, you can also publish the config file of the package.
Install SVG font
As a next step you need to install Font Awesome via npm:
The path to the SVG files in the npm package is configured by default.
But you can change the path via the config parameter path_to_fontawesome
in config\icons.php
if you want to.
Add Font Awesome SVG CSS-Style
To display the icons correctly you need to add an additional css file which can be found in the npm @fortawesome/fontawesome-free
package.
I would recommend using Webpack to publish the file in the public/css
directory.
Afterwards you need to add the svg-icons.css
file in the head section of your site.
In order to inherit the font color of the parent correctly you have to add the following style declaration in your global CSS file
Usage
You can now add the new @icon
blade directive to add the inline SVG icon.
The argument for the directive is the same as you would use for Font Awesome icons.
You can use the directive as followed:
Examples
Usage in a Blade view:
Usage in a Controller method or normal PHP code:
Optionally you can omit the icon string from the constructor and instead provide it in the render method like this
This package also provides an Icon Facade. Unfortunately, the way Facades work, you have to provide the icon string in the render method instead of the constructor.
First you have to 'register' the Facade in you app.php file at the end of the alias array like this
After that you can use the Facade like this
Additional Route
If the setting $config['route']['enabled']
is true (default: true),
an additional route will be registered to provide an Url-Based fetch for the SVG Icon Content.
With this route you can load the Icon via a normal GET-Operation, so you can use the Icon also in "Non Blade"-Scenarios like Vue-Components.
You can use it like this:
It will throw an Symfony\Component\HttpKernel\Exception\NotFoundHttpException
if the requested icon doesn't exist.
Examples
Accessibility
role="img"
is added to the SVG tag by defaultaria-hidden="true"
is added to the SVG tag by default unless a<title>
is set
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-svg-icons with dependencies
illuminate/contracts Version ~5.8.0|^6.0|^7.0|^8.0
illuminate/http Version ~5.8.0|^6.0|^7.0|^8.0
illuminate/support Version ~5.8.0|^6.0|^7.0|^8.0
ext-dom Version *