定制 dicebear/core 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dicebear/core

Composer 安装命令:

composer require dicebear/core

包简介

Unique avatars from dozens of styles — deterministic, customizable, vector-based.

README 文档

README

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 | Documentation

Installation

composer require dicebear/core

Requires PHP 8.2+ and the mbstring extension.

Usage

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

$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

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.

bunny.net

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固