PHP code example of husseinalhammad / fontawesome-svg
1. Go to this page and download the library: Download husseinalhammad/fontawesome-svg library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
husseinalhammad / fontawesome-svg example snippets
// $dir = directory where SVG files are
$FA = new FontAwesomeSVG($dir);
echo $FA->get_svg('fa-solid fa-file');
echo $FA->get_svg('fa-solid fa-file', ['class' => 'my-custom-class another-class']);
echo $FA->get_svg('fa-solid fa-file', ['default_class' => false]);
echo $FA->get_svg('fa-solid fa-file', ['fill' => '#f44336']);
echo $FA->get_svg('fa-solid fa-file', ['title' => 'My accessible icon']);
echo $FA->get_svg('fa-solid fa-file', [
'class' => 'my-custom-class another-class',
'default_class' => false,
'title' => 'My title',
'role' => 'img',
'fill' => '#ffffff',
]);
echo $FA->get_svg('fa-duotone fa-laugh-wink', [
'primary' => [
'fill' => '#e64980',
],
'secondary' => [
'fill' => '#fcc417',
'opacity' => '1',
],
]);
echo $FA->get_svg('fa-sharp fa-light fa-file');
echo $FA->get_svg('fa-sharp fa-regular fa-file');
echo $FA->get_svg('fa-sharp fa-solid fa-file');
echo $FA->get_svg('fad fa-laugh-wink', [
'fill' => '#e64980',
]);
echo $FA->get_svg('fad fa-laugh-wink', [
'fill' => '#e64980',
'class' => 'fa-swap-opacity',
]);
echo $FA->get_svg('fad fa-laugh-wink', [
'fill' => '#e64980',
'secondary' => [
'opacity' => '0.2',
],
]);
echo $FA->get_svg('fad fa-laugh-wink', [
'primary' => [
'fill' => '#e64980',
'opacity' => '0.5',
],
'secondary' => [
'fill' => '#fcc417',
'opacity' => '1',
],
]);
echo $FA->get_svg('fab fa-twitter');
echo $FA->get_svg('fad fa-file');
echo $FA->get_svg('fal fa-file');
echo $FA->get_svg('far fa-file');
echo $FA->get_svg('fas fa-file');
// And the new shorthands for thin and sharp
echo $FA->get_svg('fat fa-file'); // thin
echo $FA->get_svg('fasl fa-file'); // sharp-light
echo $FA->get_svg('fasr fa-file'); // sharp-regular
echo $FA->get_svg('fass fa-file'); // sharp-solid
echo $FA->get_svg('fa-solid fa-file', [
'title' => 'File',
'title_id' => 'file-id',
]);
echo $FA->get_svg('fa-solid fa-file', [
'aria-label' => 'File',
]);
echo $FA->get_svg('fa-solid fa-file');