laravel maintained by arrratars
Description
Beautifully crafted unique avatar placeholders for Laravel. A Laravel/PHP port of avvvatars. Deterministic SVG avatars generated from any string input. 60 shapes, 20 color palettes, zero dependencies.
Author
Rakan
Last update
2026/04/27 03:20
(dev-main)
License
Downloads
2
Tags
placeholder - component - laravel - avatar - svg - identicon - profile-picture - user-avatar - avvvatars
This project is literally avvvatars but for Laravel/PHP.
Same algorithm. Same 60 shapes. Same 20 color palettes. Same deterministic output.
All credit for the original design, shapes, and color system goes to:
- Nusu Alabuga (creator)
- Oguz Yagiz Kara
- Monika Michalczyk (shapes design)
Original repo: https://github.com/nusu/avvvatars
What it does
Pass any string → get a unique, deterministic SVG avatar.
The output is pure SVG. Not tied to Blade. Not tied to HTML. Use it literally anywhere.
Installation
composer require arrratars/laravel
Service provider is auto-discovered. Optionally publish the config:
php artisan vendor:publish --tag=arrratars-config
Quick Start
use Arrratars\Laravel\Facades\Arrratars;
// Get SVG string
$svg = Arrratars::svg('user@email.com');
// That's it. $svg is a complete <svg>...</svg> string.
All The Ways You Can Use It
1. API Endpoint (return as image)
// routes/api.php
Route::get('/avatar/{value}', function (string $value) {
return response(Arrratars::svg($value, ['style' => 'shape', 'size' => 128]))
->header('Content-Type', 'image/svg+xml')
->header('Cache-Control', 'public, max-age=31536000');
});
Now you can do:
<img src="https://yourapp.com/api/avatar/user@email.com" />
2. Save to S3
use Illuminate\Support\Facades\Storage;
use Arrratars\Laravel\Facades\Arrratars;
Storage::disk('s3')->put(
'avatars/user123.svg',
Arrratars::svg('user@email.com', ['size' => 256, 'style' => 'shape'])
);
3. Save to local disk
Arrratars::saveTo('user@email.com', storage_path('app/avatars/user.svg'));
// PNG (requires Imagick extension)
Arrratars::saveTo('user@email.com', storage_path('app/avatars/user.png'), [
'format' => 'png',
'size' => 256,
]);
4. Store in database
$user->avatar_svg = Arrratars::svg($user->email, ['style' => 'shape', 'size' => 128]);
$user->save();
5. Use in <img> tag via base64
$src = Arrratars::toBase64('user@email.com', ['size' => 64]);
// → data:image/svg+xml;base64,PHN2ZyB4bWxu...
<img src="{{ Arrratars::toBase64($user->email) }}" alt="avatar" />
6. Inline SVG in Blade
{!! arrratars('user@email.com') !!}
{!! arrratars('user@email.com', ['style' => 'shape', 'size' => 48]) !!}
7. Blade component
<x-arrratars value="user@email.com" />
<x-arrratars value="user@email.com" style="shape" :size="64" :shadow="true" :border="true" />
8. Helper functions
$svg = arrratars('anything'); // returns SVG string
$base64 = arrratars_base64('anything'); // returns data:image/svg+xml;base64,...
9. In JSON API responses
// app/Http/Controllers/UserController.php
public function show(User $user)
{
return response()->json([
'name' => $user->name,
'avatar_svg' => Arrratars::svg($user->email, ['style' => 'shape']),
'avatar_url' => url('/api/avatar/' . $user->email),
]);
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
style |
'character' | 'shape' |
'character' |
Initials or SVG shape |
size |
int | 32 | Size in pixels |
display_value |
string | null | Override the 2-letter text |
shadow |
bool | false | Drop shadow |
border |
bool | false | Border ring |
border_size |
int | 2 | Border width |
border_color |
string | '#fff' |
Border color |
radius |
int | size | Border radius (circle by default) |
Methods
| Method | Returns | Description |
|---|---|---|
svg($value, $options) |
string |
Complete SVG markup |
render($value, $options) |
string |
Alias for svg() |
toBase64($value, $options) |
string |
Base64 data URI for img src |
toDataUri($value, $options) |
string |
URL-encoded data URI |
toPng($value, $options) |
string |
PNG binary (needs Imagick) |
saveTo($value, $path, $options) |
bool |
Write to file |
How the output looks
The svg() method returns a self-contained SVG like this:
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<rect width="64" height="64" rx="64" ry="64" fill="#EEEDFD"/>
<text x="50%" y="50%" text-anchor="middle" dominant-baseline="central"
fill="#4409B9" font-family="..." font-size="24" font-weight="500">JD</text>
</svg>
No external dependencies. No CSS required. No JavaScript. Works everywhere SVG is supported.
Credits
PHP/Laravel port of avvvatars. All design, shapes, and colors belong to the original avvvatars team.
License
MIT