PHP library for generating identicons as PNG and SVG.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src Bug fix: enableImageMagick was not returned in the option array. Jul 21, 2018
tests Attempt to use GD instead of ImageMagick to extract pixel data from t… Jul 21, 2018
.gitignore
.travis.yml Fixed syntax error in .travis.yml. Jul 21, 2018
LICENSE
README.md Added badges to README. Jul 20, 2018
composer.json Improved testing on PHP 5.3 - 7.2. Jul 20, 2018

README.md

Jdenticon-php

PHP library for generating highly recognizable identicons.

Sample identicons

Build Status Total Downloads

Features

Jdenticon-php is a PHP port of the JavaScript library Jdenticon.

  • Renders identicons as PNG or SVG with no extension requirements.
  • Runs on PHP 5.3 and later.

Live demo

https://jdenticon.com

Getting started

Using Jdenticon is simple. Follow the steps below to integrate Jdenticon into your website.

1. Install the Jdenticon Composer package

The easiest way to get started using Jdenticon for PHP is to install the Jdenticon Composer package.

composer require jdenticon/jdenticon

2. Create a php file that will serve an icon

Now create a file that you call icon.php and place it in the root of your application. Add the following content to the file.

<?php
include_once("vendor/autoload.php");

// Set max-age to a week to benefit from client caching (this is optional)
header('Cache-Control: max-age=604800');

// Parse query string parameters
$value = $_GET['value'];
$size = min(max(intval($_GET['size']), 20), 500);

// Render icon
$icon = new \Jdenticon\Identicon();
$icon->setValue($value);
$icon->setSize($size);
$icon->displayImage('png');

3. Use icon.php

Open up your favourite browser and navigate to http://localhost:PORT/icon.php?size=100&value=anything. An identicon should be displayed. Try to change the url parameters to see the difference in the generated icon.

Other resources

API documentation

For more usage examples and API documentation, please see:

https://jdenticon.com/php-api.html

License

Jdenticon-php is released under the MIT license.