Icons and icon factories

All icon libraries support assistive reading technologies.

Font Awesome

Font Awesome icons can be used by creating a Icon or a FontAwesomeIcon object.

FontAwesomeIcon Icon size can be changed simply by calling FontAwesomeIcon::setSize() method with a Font Awesome CSS class (or a short hand version of it by simply removing the fa- from the begining of the size class)

Sizes are:

  • fa-xs - .75em
  • fa-sm - .875em
  • fa-lg - 1.33em, also applies vertical-align: -25%
  • fa-2x through fa-10x - 2em through 10em


use Sphp\Media\Icons\IconObject;
use Sphp\Media\Icons\FontAwesome;

$factory = new FontAwesome();
$factory->useTitle('Factory example title');
echo new IconObject('fab fa-creative-commons');
echo $factory->createIcon('fab fa-creative-commons');
echo $factory->createIcon('fab fa-creative-commons')->setSize('2x');
echo $factory->createIcon('fab fa-html5')->setSize('3x');
echo $factory->createIcon('fab fa-python')->setSize('4x');
echo $factory->createIcon('fab fa-facebook-square')->setSize('5x');
echo $factory->createIcon('fab fa-blogger')->setSize('6x');
echo $factory->createIcon('fab fa-css3')->setSize('7x');
echo $factory->createIcon('fab fa-npm')->setSize('8x');
echo $factory->createIcon('fab fa-gulp')->setSize('9x');
echo $factory->createIcon('fab fa-sass')->setSize('10x');


Devicons icon factory uses Devicon v2 library. Devicons is a set of icons representing programming languages, designing and development tools. These icons are available as fonts and SVG images and they support assistive reading technologies.


use Sphp\Media\Icons\Devicon;
use Sphp\Media\Icons\Devicons;

$factory = new Devicons();
$factory->useTitle('Factory example title');
$list = new \Sphp\Html\Lists\Ul;
$list->append(new Devicon('devicon-devicon-plain-wordmark'))->css()->setProperty('font-size', '2rem');
        ->css()->setProperty('font-size', '2rem');
echo $list;

Other icon factories

Filetype icons and SVG country flags

Filetype icon factory

Filetype icons


use Sphp\Media\Icons\FileTypeIcons; 

$files = [
    new SplFileObject('./index.php'),
$icons = FileTypeIcons::defaultSet();
foreach ($files as $file) {
  echo $icons->createIconFor($file) . " $file
"; } $icons->setExtensionIcon('bar', 'far fa-smile'); echo $icons->createIconFor('') . " special icon for *.bar files

special icon for *.bar files

External Icon resources

  1. Font Awesome:
  2. Devicon 2.0:
  3. Jam Icons:
  4. Material Design Icons: