PHP code example of saade / facehash

1. Go to this page and download the library: Download saade/facehash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saade / facehash example snippets


use Saade\Facehash\Facades\Facehash;

// Generate an SVG string
$svg = Facehash::name('Saade')->toSvg();

// Embed as a data URI in an <img> tag
$uri = Facehash::name('Saade')->toUri();
// <img src="{{ $uri }}" alt="Avatar">

Facehash::name('[email protected]')->toSvg();

Facehash::name('Saade')->size(128)->toSvg();

Facehash::name('Saade')->variant('solid')->toSvg();

Facehash::name('Saade')->format('squircle')->toSvg();

Facehash::name('Saade')->blink()->toSvg();

Facehash::name('Saade')->initial(false)->toSvg();

Facehash::name('Saade')->colors(['#6366f1', '#8b5cf6', '#a78bfa'])->toSvg();

// config/facehash.php
'route' => [
    'enabled' => true,
    // ...
],

return [
    'defaults' => [
        'size' => 40,
        'variant' => 'gradient',  // 'gradient' or 'solid'
        'format' => 'circle',     // 'square', 'squircle', or 'circle'
        'initial' => true,
        'blink' => false,
    ],

    'colors' => ['#ec4899', '#f59e0b', '#3b82f6', '#f97316', '#10b981'],

    'route' => [
        'enabled' => false,
        'prefix' => 'facehash',
        'middleware' => ['web'],
        'cache_control' => 'public, max-age=31536000, immutable',
    ],
];
html
<!-- Basic usage -->
<img src="/facehash?name=Saade" alt="Avatar">

<!-- Larger, solid variant -->
<img src="/facehash?name=Saade&size=128&variant=solid" alt="Avatar">

<!-- Custom colors -->
<img src="/facehash?name=Saade&colors[]=%236366f1&colors[]=%238b5cf6" alt="Avatar">
bash
php artisan vendor:publish --tag=facehash-config
bash
php -S localhost:8080 demo.php