sh-sabbir / faker-php-avatar
A provider for FakerPHP/Faker to generate Avatar Based on DiceBear
dev-master
2022-02-24 07:07 UTC
Requires
- php: ^5.4 || ^7.0 || ^8.0
- ext-curl: *
- fakerphp/faker: ~1
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-24 13:24:12 UTC
README
FakerPHP Avatar
FakerPHP Avatar is an addon package for Faker to generate fake avatars based on DiceBear. It Supports all 22 styles of DiceBear.
Getting Started
Installation
FakerPHP Avatar requires Faker >= 1.0.
composer require sh-sabbir/faker-php-avatar
Documentation
Full documentation can be found over on sh-sabbir.github.io/FakerPHP-Avatar.
Basic Usage
Add Provider
$faker = Faker\Factory::create(); $faker->addProvider(new Sabbir\Faker\AvatarProvider($faker));
Default settings
$faker->avatarUrl($style = "adventurer", $size = null, $slug = null, $bg = null, $scale = null, $flip = null);
Generate Avatar URL
$url = $faker->avatarUrl(); // https://avatars.dicebear.com/api/adventurer/:seed.svg $url = $faker->avatarUrl('male'); // https://avatars.dicebear.com/api/male/:seed.svg $url = $faker->avatarUrl('male',100); // https://avatars.dicebear.com/api/adventurer/:seed.svg?size=100 $url = $faker->avatarUrl('male',100,'my-custom-slug'); // https://avatars.dicebear.com/api/adventurer/my-custom-slug.svg?size=100 $url = $faker->avatarUrl('male',100,'my-custom-slug','#cfcfcf'); // https://avatars.dicebear.com/api/adventurer/my-custom-slug.svg?b=%23cfcfcf&size=100 $url = $faker->avatarUrl('male',100,'my-custom-slug','#cfcfcf',100); // https://avatars.dicebear.com/api/adventurer/my-custom-slug.svg?size=100&b=%23cfcfcf&scale=100 $url = $faker->avatarUrl('male',100,'my-custom-slug','#cfcfcf',100,1); // https://avatars.dicebear.com/api/adventurer/my-custom-slug.svg?size=100&b=%23cfcfcf&scale=100&flip=1
Check documentation for more complex example.
Available Styles
All Settings and Default Values
License
Faker is released under the MIT License. See LICENSE
for details.