PHPackages                             rackbeat/laravel-ui-avatars - 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. rackbeat/laravel-ui-avatars

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

rackbeat/laravel-ui-avatars
===========================

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

1.2(3y ago)43144.3k↓14.7%15[2 PRs](https://github.com/Rackbeat/laravel-ui-avatars/pulls)MITPHPPHP &gt;=7.1CI failing

Since Sep 3Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Rackbeat/laravel-ui-avatars)[ Packagist](https://packagist.org/packages/rackbeat/laravel-ui-avatars)[ RSS](/packages/rackbeat-laravel-ui-avatars/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Official Laravel wrapper for
=====================================================

[](#official-laravel-wrapper-for-httpsui-avatarscom)

 [![Build Status](https://camo.githubusercontent.com/c4267b6fed5d73636e358e07c2b75a344191452178192adb241837fd77c02d5a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5261636b626561742f6c61726176656c2d75692d617661746172732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Rackbeat/laravel-ui-avatars)[![Coverage](https://camo.githubusercontent.com/cfd0fc1c40e636e0be7951e33ec3d88adf2ac444bf84d1b4da7dacff6aa5ee61/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f5261636b626561742f6c61726176656c2d75692d617661746172732e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/Rackbeat/laravel-ui-avatars)[![Total Downloads](https://camo.githubusercontent.com/47055569671f5663291b2a9e46672fcad72ae4c60a2b298389461b7f662f4871/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7261636b626561742f6c61726176656c2d75692d617661746172732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rackbeat/laravel-ui-avatars)[![Latest Stable Version](https://camo.githubusercontent.com/92f0aeef4eaeaea2ee288922cadcaaa09bc1a3938499fb4407851cf3b49ef029/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7261636b626561742f6c61726176656c2d75692d617661746172732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rackbeat/laravel-ui-avatars)[![License](https://camo.githubusercontent.com/c9908fa3cb4648ac57c749371cb19a7b921fcf467e720ac5c75a9f15ad2b116c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7261636b626561742f6c61726176656c2d75692d617661746172732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rackbeat/laravel-ui-avatars)

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

[](#installation)

You just require using composer and you're good to go!

```
composer require rackbeat/laravel-ui-avatars
```

The Service Provider is automatically registered.

Setup
-----

[](#setup)

To setup the config file, you publish it like so:

```
php artisan vendor:publish --provider="Rackbeat\UIAvatars\UIAvatarsServiceProvider"
```

You can edit the file in `config/ui-avatars.php`.

Usage
-----

[](#usage)

### 1. Add the `Rackbeat\UIAvatars\HasAvatar` trait to your Model (e.g. `App\Users`)

[](#1-add-the-rackbeatuiavatarshasavatar-trait-to-your-model-eg-appusers)

```
// ...
class User extends Authenticatable {
  use \Rackbeat\UIAvatars\HasAvatar;
  // ...
}
```

### 2. Create a new method on your Model.

[](#2-create-a-new-method-on-your-model)

This method is practically a proxy to call the `HasAvatar` methods. It will return a gravatar from the e-mail, with a fallback to the avatar using `ui-avatars.com` API.

```
public function getAvatar( $size = 64 ) {
  return $this->getGravatar( $this->email, $size );
}
```

NOTICE: Gravatar is only available using the API, not locally generated avatars.

### 3. (Optional) Re-define the name field

[](#3-optional-re-define-the-name-field)

Assuming you're not using the default `User` Model in Laravel, you can override which field is being used for the name.

```
public function getAvatarNameKey( ) {
  return 'full_name';
}
```

Available methods
-----------------

[](#available-methods)

### `getInitials($length=null)`

[](#getinitialslengthnull)

Returns the generated initials, from the name, used in the avatar.

Default `$length` can be defined in `config/ui-avatars.php` (`length` key)

### `getUrlfriendlyAvatar($size=null)`

[](#geturlfriendlyavatarsizenull)

Return a urlfriendly formatted avatar (URL or base64).

Example usage:

```

```

Default `$size` can be defined in `config/ui-avatars.php` (`image_size` key)

### `getAvatarBase64($size=null)`

[](#getavatarbase64sizenull)

Return a base64 representation of the avatar.

Default `$size` can be defined in `config/ui-avatars.php` (`image_size` key)

### `getAvatarImage($size=null)`

[](#getavatarimagesizenull)

Return a Image object of the avatar.

Default `$size` can be defined in `config/ui-avatars.php` (`image_size` key)

### `getGravatar($email, $size=null)`

[](#getgravataremail-sizenull)

Return a link to a Gravatar image using the specified email, and a fallback to using our own generator (assuming provider = `api`)

Default `$size` can be defined in `config/ui-avatars.php` (`image_size` key)

Available options
-----------------

[](#available-options)

In the config file you can specify different options.

KeyDescriptionDefaultAvailable Options / TypeproviderWhich provider to use for generating avatars.`api``local` or `api`lengthMax initials length (amount of letters)`2`Number, min: 1, max: unlimitedimage\_sizeDefault width &amp; height for the generated avatar.`48`Number, min: 1, max: unlimited (512 using `api` provider)font\_sizeFont size in percentage of `image_size`.`0.5`Number, min: 0, max: 1roundedShould the generated avatar be a rounded circle? (its recommended to disable and round using CSS)`false`Booleansmooth\_roundingIf `rounded` is enabled, and provider is `local`, you can enable smoother rounding with the cost of performance.`true`BooleanuppercaseShould the initials be forced uppercase or not.`true`Booleanbackground\_colorDefault HEX background color for avatars.`#a0a0a0`Hexfont\_colorDefault HEX font color for avatars.`#222`HexprovidersList of available providers. For you to add your own provider.Array of providersRequirements
------------

[](#requirements)

- PHP &gt;= 7.1

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 93% 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 ~138 days

Recently: every ~277 days

Total

13

Last Release

1158d ago

Major Versions

0.9 → 1.02022-02-14

### Community

Maintainers

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

---

Top Contributors

[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (40 commits)")[![htcang](https://avatars.githubusercontent.com/u/5163135?v=4)](https://github.com/htcang "htcang (1 commits)")[![KABBOUCHI](https://avatars.githubusercontent.com/u/9212274?v=4)](https://github.com/KABBOUCHI "KABBOUCHI (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")

---

Tags

phplaravelInitialsavatarsui-avatars

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rackbeat-laravel-ui-avatars/health.svg)

```
[![Health](https://phpackages.com/badges/rackbeat-laravel-ui-avatars/health.svg)](https://phpackages.com/packages/rackbeat-laravel-ui-avatars)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[mediconesystems/livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS

1.2k711.3k8](/packages/mediconesystems-livewire-datatables)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)

PHPackages © 2026

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