GithubHelp home page GithubHelp logo

edwinhoksberg / octicons-php Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 6.0 154 KB

A simple PHP library for displaying the Github Octicons font icons in svg format.

License: MIT License

PHP 100.00%
octicons github icons svg php library

octicons-php's Introduction

Octicons-PHP Build Status Coverage Status Packagist

A simple PHP library for displaying the Github Octicons font icons in svg format.

Installation

Installation with composer:

composer require edwinhoksberg/octicons-php

Usage

<?php

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();

Twig Extension

A simple twig function is available for those who are using the Twig templating library.

Display an icon: {{ octicon("gear") }}

Display an icon with extra css classes: {{ octicon("gear", 'background-red') }}

Display an extra large icon: {{ octicon("gear", '', 2) }}

Tests

Run the unit tests with PHPUnit:

vendor/bin/phpunit -c phpunit.dist.xml

License

MIT

octicons-php's People

Contributors

burki avatar edwinhoksberg avatar nitz avatar vidurb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

octicons-php's Issues

Twig_Extension deprecated

Hi Edwin,

Just wanted to let you know of the following deprecation message:
Using the "Twig_Extension" class is deprecated since Twig version 2.7, use "Twig\Extension\AbstractExtension" instead.

I'd be happy to submit a PR for the same, just let know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.