A simple service provider/wrapper for the DiceBear Avatars API (https://dicebear.com/).
black-sheep-tech/laravel-dice-bear is a Laravel package for a simple service provider/wrapper for the dicebear avatars api (https://dicebear.com/)..
It currently has 1 GitHub stars and 197 downloads on Packagist (latest version v1.0.0).
Install it with composer require black-sheep-tech/laravel-dice-bear.
Discover more Laravel packages by black-sheep-tech
or browse all Laravel packages to compare alternatives.
Last updated
Laravel DiceBear is a PHP library for Laravel used to generate avatar using the DiceBear API (https://dicebear.com/). This package provides a simple, fluent interface for customizing avatar parameters and generating the corresponding URL. It also allows downloading and saving the avatars locally. Support for self-hosted DiceBear API is also available.
You can install the package via Composer:
composer require black-sheep-tech/laravel-dice-bear
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();
To download the avatar directly:
// 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();
To save the avatar to a specific location:
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');
Currently, the following DiceBear styles are supported:
Most styles have options specific to them.
This package is open-sourced software licensed under the MIT license.
Contributions are welcome! Please feel free to submit a Pull Request on GitHub.