1. Go to this page and download the library: Download iconify/json-tools 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/ */
iconify / json-tools example snippets
use \Iconify\JSONTools\Collection;
$collection = new Collection();
$collectionWithPrefix = new Collection('custom-icons');
$collection = new Collection();
if (!$collection->loadFromFile('json/custom-icons.json')) {
throw new \Exception('Failed to load custom-icons.json');
}
$collection = new Collection();
if (!$collection->loadFromFile('json/custom-icons.json', null, 'cache/custom-icons.php')) {
throw new \Exception('Failed to load custom-icons.json');
}
$collection = new Collection();
// Use this if collection has prefix
if (!$collection->loadJSON($data)) {
throw new \Exception('Failed to load JSON data');
}
$collection = new Collection();
// Use this if collection is missing prefix
if (!$collection->loadJSON($data, 'custom-icons')) {
throw new \Exception('Failed to load JSON data');
}
$collection = new Collection();
if (!$collection->loadIconifyCollection('mdi')) {
throw new \Exception('Failed to load Material Design Icons');
}
$collection = new Collection();
$file = Collection::findIconifyCollection('mdi');
if (!$collection->loadFromCache('cache/mdi.php', filemtime($file))) {
if (!$collection->loadFromFile($file)) {
throw new \Exception('Cannot load Material Design Icons');
}
$collection->saveCache('cache/mdi.php', filemtime($file));
}
$data = $collection->getIconData('arrow-left');
$svg = new SVG($data);
echo $svg->getSVG();
use \Iconify\JSONTools\Collection;
use \Iconify\JSONTools\SVG;
$collection = new Collection();
$collection->loadIconifyCollection('mdi');
$svg = new SVG($collection->getIconData('home'));
echo $svg->getSVG();
$svg->getSVG([
'height' => '24px'
]);
$svg->getSVG([
'height' => '24px',
'width' => '24px',
'align' => 'center,middle,meet',
'color' => '#ff8000',
'rotate' => '90deg', // same as "'rotate' => 1" or "'rotate' => '25%'"
'flip' => 'horizontal', // same as "'hFlip' => true"
'box' => true
]);
$svg->getSVG([
'height' => 'auto' // height and width will be set from viewBox attribute, using original icon's dimensions
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.