PHP code example of yassinedoghri / php-icons
1. Go to this page and download the library: Download yassinedoghri/php-icons 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/ */
yassinedoghri / php-icons example snippets
echo icon('material-symbols:bolt');
// <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
// <path fill="currentColor" d="m8 22l1-7H4l9-13h2l-1 8h6L10 22z"/>
// </svg>
echo icon('material-symbols:bolt', [
'class' => 'text-2xl',
'style' => 'color: yellow;'
]);
// <svg class="text-2xl" style="color: yellow;" […]>…</svg>
echo icon('material-symbols:bolt')
->attr('class', 'text-2xl')
->attr('style', 'color: yellow;');
// <svg class="text-2xl" style="color: yellow;" […]>…</svg>
echo icon('material-symbols:bolt')
->attributes([
'class' => 'text-2xl',
'style' => 'color: yellow;'
]);
// <svg class="text-2xl" style="color: yellow;" […]>…</svg>
echo icon('ri:php-fill') // identified "ri:php-fill"
// @icon('ri:heart-fill') --> identified "ri:heart-fill"
# @icon('ri:home-fill') --> identified "ri:home-fill"
/*
* @icon('ri:user-fill') --> identified "ri:user-fill"
* @icon('ri:group-fill') --> identified "ri:group-fill"
*/
declare(strict_types=1);
use PHPIcons\Config\PHPIconsConfig;
return PHPIconsConfig::configure()
->withPaths([
__DIR__ . '/src'
])
->withDefaultPrefix('')
->withPlaceholder('�');
// in your config file
->withLocalIconSets([
'custom' => '/path/to/my-custom-set',
])
// ✅ ALL GOOD
echo icon('custom:heart');
echo icon('custom:rocket');
echo icon('custom:star');
echo icon('custom:user');
// ❌ ICONS NOT FOUND
echo icon('custom:banana');
echo icon('custom:key');
// this
echo icon('bolt');
// same as this
echo icon('material-symbols:bolt');
sh
vendor/bin/php-icons init