https://github.com/dicebear/php-core
PHP implementation of DiceBear. Read-only subtree split of dicebear/dicebear - please open issues there.
https://github.com/dicebear/php-core
Last synced: about 2 months ago
JSON representation
PHP implementation of DiceBear. Read-only subtree split of dicebear/dicebear - please open issues there.
- Host: GitHub
- URL: https://github.com/dicebear/php-core
- Owner: dicebear
- License: mit
- Created: 2026-04-01T20:37:29.000Z (3 months ago)
- Default Branch: 10.x
- Last Pushed: 2026-04-11T21:06:43.000Z (2 months ago)
- Last Synced: 2026-04-11T23:15:55.984Z (2 months ago)
- Language: PHP
- Homepage: https://github.com/dicebear/dicebear
- Size: 57.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DiceBear Core (PHP)
PHP implementation of the DiceBear avatar library. Generates deterministic SVG avatars from style definitions and a seed string.
DiceBear is available for multiple languages. All implementations share the same PRNG and rendering pipeline, producing identical SVG output for the same seed, style, and options — regardless of the language used.
[Playground](https://www.dicebear.com/playground) |
[Documentation](https://www.dicebear.com/introduction)
## Installation
```sh
composer require dicebear/core
```
Requires PHP 8.2+ and the `mbstring` extension.
## Usage
```php
use DiceBear\Avatar;
// From a style definition (JSON-decoded array)
$definition = json_decode(file_get_contents('path/to/style.json'), true);
$avatar = new Avatar($definition, [
'seed' => 'John Doe',
'size' => 128,
]);
echo $avatar; // SVG string
echo $avatar->toDataUri(); // data:image/svg+xml;charset=utf-8,...
```
### With options
```php
$avatar = new Avatar($definition, [
'seed' => 'Jane',
'size' => 64,
'flip' => 'horizontal',
'backgroundColor' => ['#0077b6', '#00b4d8'],
'backgroundColorFill' => 'linear',
'scale' => [0.8, 1.0],
'borderRadius' => 10,
]);
```
### Using the Style class
```php
use DiceBear\Style;
use DiceBear\Avatar;
use DiceBear\OptionsDescriptor;
$style = new Style($definition);
// Inspect available options for a style
$descriptor = new OptionsDescriptor($style);
$fields = $descriptor->toJSON();
// Create multiple avatars from the same style
$avatar1 = new Avatar($style, ['seed' => 'Alice']);
$avatar2 = new Avatar($style, ['seed' => 'Bob']);
```
## License
The source code of DiceBear is released under the **MIT License**.
## Sponsors
Advertisement: Many thanks to our sponsors who provide us with free or discounted products.