PHP code example of black-sheep-tech / laravel-dice-bear

1. Go to this page and download the library: Download black-sheep-tech/laravel-dice-bear 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/ */

    

black-sheep-tech / laravel-dice-bear example snippets


use BlackSheepTech\DiceBear\DiceBear;

// Generates a random avatar using the 'botttsNeutral' style with a size of 128 pixels and 'Avesome Avatar Seeder' as seed.

$avatarUrl = DiceBear::style('botttsNeutral')->seed('Avesome Avatar Seeder')->size(128)->getUrl();

// Alternatively, you can use the following shorthand method:

$avatarUrl = DiceBear::botttsNeutral()->seed('Avesome Avatar Seeder')->size(128)->getUrl();


// Prompts a download of the avatar to a file named 'john_doe_avatar.png', by default, if a file name is not provided, a random name will be generated.
use BlackSheepTech\DiceBear\DiceBear;

DiceBear::botttsNeutral()->seed('John Doe')->size(128)->download();

use BlackSheepTech\DiceBear\DiceBear;

// Saves the avatar to 'avatars/john_doe_avatar.png' by default.
$avatarPath = DiceBear::botttsNeutral()->seed('John Doe')->size(128)->saveTo('avatars', 'john_doe_avatar');

// You can provided the disk to be used as the third parameter, by default, the application's default disk will be used.
$avatarPath = DiceBear::botttsNeutral()->seed('John Doe')->size(128)->saveTo('avatars', 'john_doe_avatar', 'public');