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

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

juanrube/laravel-ui-avatars
===========================

Fork and refactor of Rackbeat/laravel-ui-avatars. Official Laravel wrapper around ui-avatars.com and LasseRafn/php-initial-avatar-generator

1.0(1y ago)06MITPHPPHP &gt;=8.1

Since Apr 23Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (0)

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

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

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

[](#installation)

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

```
composer require juanrube/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="Juanrube\UIAvatars\UIAvatarsServiceProvider"
```

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

Usage
-----

[](#usage)

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

[](#1-add-the-juanrubeuiavatarshasavatar-trait-to-your-model-eg-appmodelsusers)

```
// ...
class User extends Authenticatable {
  use \Juanrube\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;= 8.1
- Laravel &gt;=10

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance48

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.6% 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

Unknown

Total

1

Last Release

384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0503978603e7f72b2ca37cf37abf33368618884e39deecc597ef36497cd07f63?d=identicon)[jrube](/maintainers/jrube)

---

Top Contributors

[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (40 commits)")[![juanrube](https://avatars.githubusercontent.com/u/186569526?v=4)](https://github.com/juanrube "juanrube (6 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/juanrube-laravel-ui-avatars/health.svg)

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

###  Alternatives

[rackbeat/laravel-ui-avatars

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

43144.3k](/packages/rackbeat-laravel-ui-avatars)[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)

PHPackages © 2026

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