Download the PHP package mbonghanoy/avatar without Composer
On this page you can find all versions of the php package mbonghanoy/avatar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package avatar
mbonghanoy/avatar
Generate simple SVG avatars from names or labels.
Features
- Deterministic background colors based on the input text
- UTF-8 safe initials generation
- Circle and square avatar shapes
- SVG output or base64 data URI output
- No external runtime dependencies beyond
ext-mbstring
Installation
Usage
API
Avatar::make(string $text): Avatar
Creates a new avatar instance using the provided text.
size(int $size): Avatar
Sets the avatar width and height in pixels.
- The size must be greater than
0.
background(string $color): Avatar
Sets the background color using a hex value like #fff or #ffffff.
color(string $color): Avatar
Sets the text color using a hex value like #fff or #ffffff.
circle(): Avatar
Renders the avatar as a circle.
square(): Avatar
Renders the avatar as a square.
svg(): string
Returns the generated avatar as an SVG string.
toDataUri(): string
Returns the generated avatar as a base64-encoded SVG data URI.
Example Output
Returns SVG similar to:
Testing
Run the local test suite with:
License
MIT
All versions of avatar with dependencies
PHP Build Version
Package Version
Requires
ext-mbstring Version
*
The package mbonghanoy/avatar contains the following files
Loading the files please wait ...