Documentation
PHP Blockies
The php alternative for download13/blockies js package.

$blockies = new \IsaEken\Blockies\Blockies;
$blockies->draw();
echo $blockies->svg(); // <svg...
$blockies->image()->save('image.jpg'); // save generated image
echo $blockies->image()->encode('data-url')->encoded; // data:image/png;base64...
Installation
You can install with using composer.
composer require isaeken/blockies
Usage
Create the instance first.
$blockies = new \IsaEken\Blockies\Blockies([
'seed' => '130ef2f0a8b713',
'size' => 64,
'background' => \Spatie\Color\Hex::fromString('#ff0000')->toHsl(),
]);
// or
$blockies = new \IsaEken\Blockies\Blockies;
draw them.
$blockies->draw();
You can use this as SVG.
file_put_contents('image.svg', $blockies->svg());
or use this with Intervention\Image
$blockies->image()->greyscale()->save('black_and_white.jpg');
recreate your seed
$blockies->refresh();
$blockies->image(); // this is a new image.
resize and change background
$blockies
->setSize(120)
->setBackground(\Spatie\Color\Hex::fromString('#00ff00')->toHsl())
->draw()
->image();
change seed
$blockies->setSeed('130ef2f0a8b713')->draw()->image();
get values
$blockies->getSeed(); // string
$blockies->getBackground(); // \Spatie\Color\Hsl
$blockies->getSize(); // int
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.