承接 black-sheep-tech/laravel-dice-bear 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

black-sheep-tech/laravel-dice-bear

最新稳定版本:v1.0.0

Composer 安装命令:

composer require black-sheep-tech/laravel-dice-bear

包简介

A simple service provider/wrapper for the DiceBear Avatars API (https://dicebear.com/).

README 文档

README

BlackSheepTech UiAvatars

Current Version Total Downloads License Stars

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.

Installation

You can install the package via Composer:

composer require black-sheep-tech/laravel-dice-bear

Usage

Basic Usage (All Styles)

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

Download Avatar

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

Save Avatar Directly to Disk

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

Supported Styles

Currently, the following DiceBear styles are supported:

Style Specific Options

Most styles have options specific to them.

  • BotttsNeutral - Detailed Options
    • Eyes
    • Mouth
  • AdventurerNeutral - Detailed Options
    • Eyebrows
    • Eyes;
    • Mouth
    • Glasses
    • Glasses Probability
  • Initials - Does not support any additional options

Requirements

  • PHP 8.0 or higher
  • Laravel framework version 9.0 or higher

License

This package is open-sourced software licensed under the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request on GitHub.

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-04