Skip to content
πŸ•Š PHP Library for
Branch: master
Clone or download
Pixelrobin Merge pull request #4 from KubqoA/master
Remove the dot in require statement.
Latest commit 54fe84a Jan 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Remove extraneous line in build.js Oct 29, 2018
src Remove the dot in require statement. Dec 25, 2018
tests Update Feather icons to 4.9.0 Dec 21, 2018
.gitattributes Ignore some files on export Oct 28, 2018
LICENSE Add a LICENSE Oct 28, 2018 v1.0 Oct 31, 2018
composer.json Change name to 'php-feather' Oct 28, 2018
composer.lock Add Composer support Oct 28, 2018
package-lock.json Update Feather icons to 4.9.0 Dec 21, 2018
package.json Update Feather icons to 4.9.0 Dec 21, 2018


PHP Library for Feather.

For more information on Feather itself, please refer to their README.

This project is still pretty young, and I'm still a little new to PHP. Suggestions are welcome!


php-feather uses Composer. Run the following to install it.

composer require pixelrobin/php-feather

If you want to install composer without all the tests and nodejs stuff, use --prefer-dist.

composer require pixelrobin/php-feather --prefer-dist

Then, don't forget to autoload your Composer packages!

require 'vendor/autoload.php';


Get an icon

Icons echo by default.

require 'vendor/autoload.php';
$icons = new Feather\Icons;

<!-- Display the 'anchor' icon !-->
<?php $icons->get('feather'); ?>

<!-- Get creative! !-->
<button class="icon-button">Learn More <?php $icons->get('arrow-right'); ?></button>

Get an icon with modified properties

Simply pass an array with the attributes you want. This will be merged over the Icons class default attributes, except for class, which gets concatenated to the default classes.

$icons->get('feather', array('class' => 'fooclass', 'stroke-width' => 1, 'aria-label' => 'Battery icon'));
// <svg ... class="feather feather-feather fooclass", stroke-width="1", aria-label="Battery icon" ... >...</svg>

You can also change the default attributes in the Icons class if you want some attributes consistent across multiple get calls. The passed attributes are merged over the current default attributes in the class by default.

    'color' => 'red',
    'stroke-width' => 3

// <svg ... color="red" stroke-width="3" ... >...</svg>

Get an icon as a string

Set the third argument to false to get a string instead of echoing the icon.

$icon_string = $icons->get('activity', array(), false);
// Then do whatever with $icon_string




$icons = new Feather\Icons;

Feather\Icons->get($name, $attributes = array(), $echo = true)

Gets an icon as svg. Can be echoed (default) or returned as a string. Attributes passed will be merged over the class defaults.

$icons = new Feather\Icons;

// Echo an icon
// <svg ... >...</svg>

// Echo an icon with modified properties
$icons->get('battery', array('class' => 'fooclass', 'stroke-width' => 1, 'aria-label' => 'Battery icon'));
// <svg ... class="feather feather-battery fooclass", stroke-width="1", aria-label="Battery icon" ... >...</svg>

// Get an icon as a string without echoing it
$cloud_icon = $icons->get('cloud', array(), false);


Argument Type Description
$name string The name of the icon. A full list can be found here.
$attributes? array Attributes to modify/add (see 'Usage' above for example)
$echo? boolean Whether to echo the icon svg (true) or not (false)

Feather\Icons->setAttributes($attributes, $merge = true)

Sets default attributes of the class. These are used as default attributes for the get method. By default, the $attributes argument is merged over the current default attributes in the class. You can disable this by setting the $merge argument to false, but only do it if you know what you are doing.

$icons = new Feather\Icons;

// Set some default attributes (this will be merged with the current defaults in the class)
$icons->setAttributes(array('color' => 'red', 'stroke-width' => 3));

// Now they will be included with every icon
// <svg ... color="red" stroke-width="1" ... >...</svg>


Argument Type Description
$attributes array Attributes to add
$merge? boolean Whether to merge with the current attributes (true) or replace them (false)


Get the current default attributes for the class. To set it, use the setAttributes() method;

$icons = new Feather\Icons;

$attrs = $icons->getAttributes();


Constant array of default attributes. They are applied to every new Icons class. You can use this to reset the attributes of an Icons class.

$icons = new Feather\Icons;

// Add/modify some default attributes
$icons->setAttributes( ... );

// ... do some stuff ...

// Now say you want to reset the attributes you modified to the default...
// Set merge to false to overwrite instead of merge the arrays
$icons->setAttributes(Feather\DEFAULT_ATTRIBUTES, false);


Feel free to open up issues and PRs for suggesstions.

Developing requires both nodejs and composer. The icons are included as a node module and built for use in php.

Better contributing docs are coming soon!


Licensed under the MIT License.

The icons in this code are from Feather. It is also licensed under the MIT License.

You can’t perform that action at this time.