PHPackages                             martian/laravatar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. martian/laravatar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

martian/laravatar
=================

🚀 A lightweight and easy-to-use Laravel package that add avatars to your models

v1.0.1(2y ago)61603MITPHPPHP ^7.4|^8.0

Since Dec 29Pushed 2y agoCompare

[ Source](https://github.com/amplifiedhq/laravatar)[ Packagist](https://packagist.org/packages/martian/laravatar)[ Docs](https://github.com/amplifiedhq/laravatar)[ RSS](/packages/martian-laravatar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

Laravatar
=========

[](#laravatar)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ad2cd44e248133e547fff47ac3467186e28956509b90b9065f2b77567a1b2536/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61727469616e2f6c61726176617461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martian/laravatar)[![Total Downloads](https://camo.githubusercontent.com/cfc91d0654fc479ff8cc0cc4cd24683cabe07e029322ebba540b98db05b46008/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61727469616e2f6c61726176617461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martian/laravatar)[![GitHub Actions](https://github.com/amplifiedhq/laravatar/actions/workflows/main.yml/badge.svg)](https://github.com/amplifiedhq/laravatar/actions/workflows/main.yml/badge.svg)

🚀 A lightweight and easy-to-use Laravel package designed to simplify avatar generation for your Eloquent models. It provides a flexible and extensible solution for generating avatars using [Gravatar](https://gravatar.com), [DiceBear](https://www.dicebear.com/), [UI Avatars](https://ui-avatars.com/) or [Boring Avatar](https://boringavatars.com/)

Supported Avatar Drivers
------------------------

[](#supported-avatar-drivers)

DriverDescriptionSupportedLinkGravatarGravatar is a service for providing globally unique avatars.Yes ✅️[Gravatar](https://gravatar.com)DiceBearDiceBear is an avatar library for designers and developers.Yes ✅️[DiceBear](https://www.dicebear.com/)UI AvatarsUI Avatars is an avatar library for designers and developers.Yes ✅️[UI Avatars](https://ui-avatars.com/)Boring AvatarBoring avatars is a tiny JavaScript React library that generates custom, SVG-based, round avatars from any username and color palette.Yes ✅️[Boring Avatar](https://boringavatars.com/)Note

You can also add your own custom driver by implementing the `AmplifiedHQ\Laravatar\Contracts\AvatarInterface;` interface and extending the `AmplifiedHQ\Laravatar\Abstracts\BaseAvatar` class.

Installation
------------

[](#installation)

> Note: This package requires PHP 7.4 or higher. You can install the package via composer:

```
composer require martian/laravatar
```

Register Service Provider
-------------------------

[](#register-service-provider)

Add the service provider to the providers array in `config/app.php`:

```
AmplifiedHQ\Laravatar\Providers\LaravatarServiceProvider::class,
```

Publish Configuration File
--------------------------

[](#publish-configuration-file)

Publish the configuration file using the following command:

```
php artisan vendor:publish --provider="AmplifiedHQ\Laravatar\Providers\LaravatarServiceProvider" --tag="config"
```

Configuration
-------------

[](#configuration)

You can configure the package by editing the `config/laravatar.php` file.

- In the configuration file you can specify the default avatar driver to use across your application.

```
'default' => env('LARAVATAR_DRIVER', 'gravatar'),
```

- If you want to change the default options for a driver, you can do so by editing the `config/laravatar.php` file.

```
'drivers' => [
    ...
    'gravatar' => [
            'class' => \AmplifiedHQ\Laravatar\Drivers\Gravatar::class,
            'options' => [
                'size' => 96,
            ],
        ],
    ...
],
```

Usage
-----

[](#usage)

In order to use the package in your model to generate an avatar on the fly, you need to add the `AmplifiedHQ\Laravatar\Traits\HasAvatar` trait to your model.

### Using the `HasAvatar` trait

[](#using-the-hasavatar-trait)

```
namespace App\Models;

use AmplifiedHQ\Laravatar\HasAvatar;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, HasAvatar;

    /** @var Avatar Column */
    protected $avatarColumn = 'email';

    /** @var Avatar Storage Column */
    protected $avatarStorageColumn = 'avatar';

    ...
}
```

Important

If you are using the `gravatar` driver, you need to use the email column as the avatar column. If you are using the `dicebear` or `ui-avatars` or `boringavatar` driver, you can use any column as the avatar column, provided that the column is a string column. (e.g. `name`, `email`, `username` etc.)

Warning

The `HasAvatar` trait requires you to define the `$avatarColumn` and `$avatarStorageColumn` properties in your model. The `$avatarColumn` property is the column that will be used to generate the avatar. The `$avatarStorageColumn` property is the column that will be used to store the avatar.

### Using the Driver Methods

[](#using-the-driver-methods)

You can also use each driver method directly on your application either on on your controller, model or view.

#### Gravatar

[](#gravatar)

```
use AmplifiedHQ\Laravatar\Drivers\Gravatar;
use App\Http\Controllers\Controller;

class UserController extends Controller {

    public function generateAvatar()
    {
        $gravatar = new Gravatar('jane@example.com');
        $gravatar->setSize(100);
        $gravatar->getUrl(); // https://www.gravatar.com/avatar/9e26471d35a78862c17e467d87cddedf?size=100
    }
}
```

#### DiceBear

[](#dicebear)

```
use AmplifiedHQ\Laravatar\Drivers\DiceBear;
use App\Http\Controllers\Controller;

class UserController extends Controller {

    public function generateAvatar()
    {
        $dicebear = new DiceBear('Jane Doe');
        $dicebear->setStyle('lorelei');
        $dicebear->setSize(100);
        $dicebear->setFormat('svg');
        $dicebear->getUrl(); // https://api.dicebear.com/7.x/lorelei/svg?seed=Jane%20Doe&size=100
    }
}
```

#### Boring Avatar

[](#boring-avatar)

```
use AmplifiedHQ\Laravatar\Drivers\BoringAvatar;
use App\Http\Controllers\Controller;

class UserController extends Controller {

    public function generateAvatar()
    {
        $boringAvatar = new BoringAvatar('Jane Doe');
        $boringAvatar->setSize(100);
        $boringAvatar->setFormat('svg');
        $boringAvatar->setVariant('marble');
        $boringAvatar->setSquare(true);
        $boringAvatar->getUrl(); // https://boring-avatars-api.vercel.app/api/avatar?size=100&variant=marble&name=Jane%20Doe&sqaure=1
    }
}
```

#### UI Avatars

[](#ui-avatars)

```
use AmplifiedHQ\Laravatar\Drivers\UiAvatars;
use App\Http\Controllers\Controller;

class UserController extends Controller {

    public function generateAvatar()
    {
        $uiAvatars = new UiAvatars('Jane Doe');
        $uiAvatars->setSize(100);
        $uiAvatars->setFormat('svg');
        $uiAvatars->setBackgroundColor('000000'); // Hexadecimal
        $uiAvatars->setForegroundColor('ffffff'); // Hexadecimal
        $uiAvatars->setRounded(true);
        $uiAvatars->getUrl(); // https://ui-avatars.com/api/?name=Jane%20Doe&size=100&background=000000&color=ffffff&rounded=true
    }
}

```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Josiah Endurance](https://github.com/hendurhance)
- [AbdulHameed](https://github.com/AbdulHameedAnofi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

868d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1a2a17381645674b6254cd41641c17218986676b167821631faec6d0fd7f664?d=identicon)[hendurhance](/maintainers/hendurhance)

---

Top Contributors

[![hendurhance](https://avatars.githubusercontent.com/u/50846992?v=4)](https://github.com/hendurhance "hendurhance (6 commits)")[![AbdulHameedAnofi](https://avatars.githubusercontent.com/u/92869818?v=4)](https://github.com/AbdulHameedAnofi "AbdulHameedAnofi (1 commits)")

---

Tags

phplaravellaravel 8laravel 10laravel-packagegravataravataravatarsui-avatarsDiceBearboring-avatarsamplifiedhq

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/martian-laravatar/health.svg)

```
[![Health](https://phpackages.com/badges/martian-laravatar/health.svg)](https://phpackages.com/packages/martian-laravatar)
```

###  Alternatives

[laravolt/avatar

Turn name, email, and any other string into initial-based avatar or gravatar.

2.0k5.4M31](/packages/laravolt-avatar)[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[rackbeat/laravel-ui-avatars

Official Laravel wrapper around ui-avatars.com and LasseRafn/php-initial-avatar-generator

43144.3k](/packages/rackbeat-laravel-ui-avatars)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[erag/laravel-pwa

A simple and easy-to-use PWA (Progressive Web App) package for Laravel applications.

16083.3k](/packages/erag-laravel-pwa)[waad/laravel-profanity-filter

Laravel Profanity Filter - Powerful PHP package for detecting, filtering, and masking profanity in multiple languages. Supports leet speak, custom word lists, case sensitivity, and seamless Laravel integration.

202.9k](/packages/waad-laravel-profanity-filter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
