Skip to content

A simple package to help you generate avatars for your users using dice bear

License

Notifications You must be signed in to change notification settings

RichardJesse/diceBearPhp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dice Bear Image

Packagist Downloads PHP Version Current Version

Dice Bear for Php

This is a simple package that is aimed at making getting avatars from Dice Bear easy in your php application.No official affiliation with the original dice bear

Installation

To install the package all you need to do is run this command in your terminal.(assuming that you have composer installed)

 composer require jesse-richard/dice-bear-php

How to use

Using diceBearPhp is pretty easy all use need to do is make use of the NeedsAvatar Trait and you'll be good to go.

use JesseRichard\DiceBearPhp\Trait\NeedsAvatar;

class User {
    use NeedsAvatar;
}

Utilities

This package provides some utilities to make the experience with the dice Bear easy.

Styles

Dice Bear offers a couple of styles that you can take advantage of and the package supports all the available styles. This package provides for three ways to make use of the Dice Bear Styles. You can have a look at all the styles here

// 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()

Format

The avatars that are provided by the Dice Bear Api are in different file formats. The package provides a method to allow you to get the file in the format that you find most convinient. Supported format

// 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')

Avatar alternatives

The avatars that are provided by Dice Bear are essentially image files. The package gives you the autonomy to choose what to do with them.

// 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()

Contributions

Contributions are highly welcomed. Feel free to fork the repo, play around to make it better.In case of any issues feel free to open an issue and i'll be right to it.A star wouldn't hurt.😉

About

A simple package to help you generate avatars for your users using dice bear

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages