PHP via Composer

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

composer require jdenticon/jdenticon

Save the following code as icon.php in the root of your application.

<?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');

Open up your favourite browser and navigate to http://localhost:<port>/icon.php?size=100&value=anything.