1. Go to this page and download the library: Download jesse-richard/dice-bear-php 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/ */
jesse-richard / dice-bear-php example snippets
use JesseRichard\DiceBearPhp\Trait\NeedsAvatar;
class User {
use NeedsAvatar;
}
// say the NeedsAvatar Trait is in use in the user class
$user = new User();
// You may choose to get a random style using the randomStyle() method like so
$user->randomStyle()
// You may choose to use the style as a method and optionally pass in the format you want it to be in using camelCase eg(big ears Neutral)
$user->bigEarsNeutral('svg')
// or
$user->bigEarsNeutral()
// getting the avatar in jpeg format
$user->format('jpeg')
// The alternative way of passing the format is while using the stlyle as a method as had been shown
$user->bigEarsNeutral('svg')
// You may choose to get the image content and maybe do something with it
$user->getContent()
// You may choose to save the image locally and extract the path of the image
$user->saveImage('path/to/avatars_folders')->savedPath()
// You may only be intrested in the Url of the image
$user->url()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.