PHPackages                             elijahcruz/avatar - 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. [Image &amp; Media](/categories/media)
4. /
5. elijahcruz/avatar

ActiveLibrary[Image &amp; Media](/categories/media)

elijahcruz/avatar
=================

Generate an avatar for your users using Gravatar and more

2.1.7(3y ago)01.1kMITPHP

Since Jun 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/elijahcruz12/php-avatars)[ Packagist](https://packagist.org/packages/elijahcruz/avatar)[ RSS](/packages/elijahcruz-avatar/feed)WikiDiscussions master Synced 3w ago

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

PHP Avatars
===========

[](#php-avatars)

Generate avatars quickly and easily through one simple to use class.

PHP Avatars was created with one VERY simple goal in mind, to be able to generate a URL for avatars, without memorizing the options that Avatar generators and providers such as Gravatar and UI Avatars provide.

COMING SOON: I will be adding built-in integration to Laravel, which will allow you to use a Facade to generate the URLs.

Requirements
------------

[](#requirements)

There are ZERO requirements, other than needing PHP, needing Componser, and the website you're wanting to add PHP Avatars to. That's it.

Install
-------

[](#install)

Installing is as simple as requiring it in Composer.

```
composer require elijahcruz/avatars

```

Usage
-----

[](#usage)

Using PHP Avatars is made to be very simple, however even though it's very simple, it has the ability to enable you to do everthing that each provider normally should allow you to do. For example, set the default in Gravatar, or set the background and color in UI Avatars.

Basic Example:

```
use Elijahcruz\Avatars\Avatar;

$avatar = new Avatar('johndoe@example.com')

$avatar->getUrl();

```

This is all is takes to load the users Gravatar. However, you can also have options as well. And there are multiple ways to do this:

```
// Through initialization
$avatar = new Avatar('johndoe@example.com', 'gravatar', ['default' => 'mp', 'size' => 200]);

// Using the option() method

$avatar->option('size', 200);

// Add multiple using the options() method
$avatar->options(['default' => 'mp', 'size' => 200]);

```

As you may have noticed, when initializing PHP Avatar, the 2nd parameter is which generator you are using. You can also specify which type using it's method:

```
// Using Gravatar
$avatar->gravatar();

// Using UI Avatars
$avatar->uiavatars();

```

This allows you to switch between avatar generators quickly and easily. But what if each one uses different options, or you wanted to generate the URL again, but with a different size, no problem. Any options that aren't defined in the generator your currently using are ignored. Any that are, can be overwritten.

When using these, you can also add the new identifier with this.

```
// Using Gravatar
$avatar->gravatar('johndoe@example.com');

// Using UI Avatars
$avatar->uiavatars('John Doe');

```

```
// Create an option then rewrite it
$avatar->option('size', 200); // Size is 200
$avatar->option('size', 400); // Size is now 400

```

You can also reset all options to a blank slate using the resetOptions() method. If you add an array to this, it will reset the array then add those options to it.

```
// Reset the options, but maybe redefine them later?
$avatar->resetOptions()

// Reset and change the options
$avatar->resetOptions(['size' => 400]);

```

But what if you wanted to also change from using an email, to the person's name, so UI Avatars shows an actual name? No problem. Just use the newIdentifier() method;

```
$avatar->newIdentifier('John Doe');

```

The best part about all of this? They can be chained!

```
$avatar->option('size', 200)->option('default' , 'mp')->option('rating', 'pg')->gravatar()->getUrl();

```

This is what makes PHP Avatars super simple, but VERY powerful.

This is all is takes to easily manage your avatars for your users.

Laravel Usage
-------------

[](#laravel-usage)

The package now thankfully has Laravel support. You can now use a Facade that includes two amazing methods.

```
use Elijahcruz\Avatar\Facades\Avatar;

Avatar::create('email', 'gravatar', ['size' => 80]);

--- OR ---
use App\Models\User;

$user = User::find(1);
Avatar::createUsingUser($user, 'name', 'uiavatar', ['size' => 80]);

```

With the facade, you can still chain the existing methods that the framework agnostic version contains.

```
Avatar::createUsingUser($user, 'email', 'gravatar')->option('size', 80)->getUrl();

```

This makes is very easy to use inside of Laravel.

If you use UI Avatar more than gravatar, or want to change some other setting, you can always publish the config file:

```
php artisan vendor:publish --provider="Elijahcruz\Avatar\AvatarPackageServiceProvider" --tag="config"

```

Currently Supported Proviers
============================

[](#currently-supported-proviers)

Meanwhile there are so many options in terms of providers out there, we're working on making as many as possible work with PHP Avatars, to give you the best possible package for this. Each provider's own options that they provide are included in PHP Avatars, to make things VERY simple.

Gravatar
--------

[](#gravatar)

Identifier Type: email

Options:

OptionTypeAcceptsdefaultstringmp, 404, identicon, monsterid, wavatar, retro, robohash, blankforce\_defaultbooltrue, falseratingstringg, pg, r, xsizeintAny integerextensionstring.jpgUI Avatar
---------

[](#ui-avatar)

Identifier Type: Name

Options:

OptionTypeAcceptsDefaultsizeint16-51264font\_sizeint0.1-10.5lengthintAny int2roundedbooltrue, falsefalseboldbooltrue, falsefalsebackgroundstringany hexf0e9e9colorstringany hex8b5d5duppercasebooltrue, falsetrueformatstringsvg, pngDepends on Accepts Header, if SVG is in header, is SVG, else PNG

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~41 days

Recently: every ~0 days

Total

16

Last Release

1223d ago

Major Versions

0.0.1 → 1.0.02021-06-26

1.0.2 → 2.0.02021-07-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14031707?v=4)[Elijah Cruz](/maintainers/elijahcruz12)[@elijahcruz12](https://github.com/elijahcruz12)

---

Top Contributors

[![elijahcruz12](https://avatars.githubusercontent.com/u/14031707?v=4)](https://github.com/elijahcruz12 "elijahcruz12 (28 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elijahcruz-avatar/health.svg)

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

###  Alternatives

[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495240.6k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

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