PHP code example of edwinhoksberg / octicons-php

1. Go to this page and download the library: Download edwinhoksberg/octicons-php 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/ */

    

edwinhoksberg / octicons-php example snippets




use Octicons\Octicon;
use Octicons\Options;

// The shortcut method:
echo Octicon::gear();

// or with options:
echo Octicon::gear([
    'classes' => ['bla', 'test-con'],
    'ratio' => 8
]);


// The extended method:
$octicon = new Octicon();
$icon = $octicon->icon('gear');

echo 'Icon name: '.$icon->getName();     // gear
echo 'Icon width: '.$icon->getWidth();   // 14
echo 'Icon height: '.$icon->getHeight(); // 16
echo 'Icon ratio: '.$icon->getRatio();   // 1

echo $icon->toSvg();

// and with custom options:
$octicon = new Octicon();
$options = new Options();

// add extra css classes:
$options->addClass('background-color');
$options->addClass(['color-blue', 'extra-class']);

// change the icon size:
$options->setRatio(2);

$icon = $octicon->icon('gear', $options);

echo 'Icon width: '.$icon->getWidth();   // 28
echo 'Icon height: '.$icon->getHeight(); // 32

echo $icon->toSvg();
bash
composer