PHPackages                             gravatarphp/gravatar - 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. gravatarphp/gravatar

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

gravatarphp/gravatar
====================

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

v2.0.0(7y ago)16625.8k—10%8[2 issues](https://github.com/gravatarphp/gravatar/issues)2MITPHPPHP ^7.1

Since Jun 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/gravatarphp/gravatar)[ Packagist](https://packagist.org/packages/gravatarphp/gravatar)[ Docs](http://gravatarphp.com)[ RSS](/packages/gravatarphp-gravatar/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (2)

Gravatar
========

[](#gravatar)

[![GitHub Workflow Status](https://camo.githubusercontent.com/335559f116322129f202a6012665c5918a9cceb2b701b06a2c321e40644380b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f67726176617461727068702f67726176617461722f43493f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/335559f116322129f202a6012665c5918a9cceb2b701b06a2c321e40644380b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f67726176617461727068702f67726176617461722f43493f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/f026f98cf550380efbe851d02cc268b4570a213b19374a44ccf14803bc8cfc1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gravatarphp/gravatar)

**Gravatar URL builder (aka. a Gravatar library)**

Install
-------

[](#install)

Via Composer

```
$ composer require gravatarphp/gravatar
```

Usage
-----

[](#usage)

Create a `Gravatar` instance and use it for creating URLs.

```
use Gravatar\Gravatar;

// Defaults: no default parameter, use HTTPS
$gravatar = new Gravatar([], true);

// Returns https://secure.gravatar.com/avatar/EMAIL_HASH
$gravatar->avatar('user@domain.com');

// Returns https://secure.gravatar.com/avatar/EMAIL_HASH
// The fourth parameter enables validation and will prevent the
// size parameter from being added to the URL generated.
$gravatar->avatar('user@domain.com', ['s' => 9001], true, true);

// Returns https://secure.gravatar.com/EMAIL_HASH
$gravatar->profile('user@domain.com');

// Returns https://secure.gravatar.com/EMAIL_HASH.vcf
$gravatar->vcard('user@domain.com');

// Returns https://secure.gravatar.com/EMAIL_HASH.qr
$gravatar->qrCode('user@domain.com');
```

You can override the globally used protocol (HTTP, HTTPS) by setting the last parameter to true/false.

```
use Gravatar\Gravatar;

$gravatar = new Gravatar();

// Returns http://www.gravatar.com/avatar/EMAIL_HASH
$gravatar->avatar('user@domain.com', [], false);

// Returns http://www.gravatar.com/EMAIL_HASH
$gravatar->profile('user@domain.com', false);

// Returns http://www.gravatar.com/EMAIL_HASH.vcf
$gravatar->vcard('user@domain.com', false);

// Returns http://www.gravatar.com/EMAIL_HASH.qr
$gravatar->qrCode('user@domain.com', false);
```

Last, but not least, you can pass default options to the builder and use them to generate avatar URLs.

```
use Gravatar\Gravatar;

$gravatar = new Gravatar([
    'size' => 500,
]);

// Returns https://secure.gravatar.com/avatar/EMAIL_HASH?size=500&r=g
$gravatar->avatar('user@domain.com', ['r' => 'g']);
```

Parameters
----------

[](#parameters)

If you pass any of the following parameters and turn validation on (fourth parameter in the `avatar()` method), their values will be checked against the allowed values defined in the [Gravatar documentation](http://gravatar.com/site/implement/):

- `s`, `size` -- The image size
- `d`, `default` -- The default image to display if there is no matching Gravatar
- `f`, `forcedefault` -- Tell Gravatar to use the default image even if there is a matching Gravatar
- `r`, `rating` -- The audience rating (`G`, `R`, etc.) to restrict the Gravatar to

If the value fails validation, an `InvalidArgumentException` will be thrown. Any parameters not listed above are not sanitized or validated in anyway.

Notes
-----

[](#notes)

Profile, vCard and QR Code requests will only work with the primary email address. This is a limitation of Gravatar. However the builder won't complain, since it doesn't know if it is your primary address or not. For more tips and details check the [Gravatar documentation](http://gravatar.com/site/implement/).

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The project is licensed under the [MIT License](LICENSE).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~469 days

Total

3

Last Release

2687d ago

Major Versions

v1.0.0 → v2.0.02019-01-08

PHP version history (2 changes)v1.0.0-alphaPHP &gt;=5.4

v2.0.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e4e105cea62b616d4cb376b08a849b6a428f646998537de150d16a8eb537b90?d=identicon)[mark.sagikazar](/maintainers/mark.sagikazar)

![](https://avatars.githubusercontent.com/u/5675248?v=4)[Mponos George](/maintainers/gmponos)[@gmponos](https://github.com/gmponos)

---

Top Contributors

[![sagikazarmark](https://avatars.githubusercontent.com/u/1226384?v=4)](https://github.com/sagikazarmark "sagikazarmark (28 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (4 commits)")[![dharple](https://avatars.githubusercontent.com/u/4107745?v=4)](https://github.com/dharple "dharple (2 commits)")[![sprak3000](https://avatars.githubusercontent.com/u/5545555?v=4)](https://github.com/sprak3000 "sprak3000 (1 commits)")

---

Tags

gravatargravatar-libraryphpimageprofilegravataravatar

### Embed Badge

![Health badge](/badges/gravatarphp-gravatar/health.svg)

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

###  Alternatives

[multiavatar/multiavatar-php

Multicultural Avatar Generator

653150.0k4](/packages/multiavatar-multiavatar-php)[creativeorange/gravatar

A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

5467.5M54](/packages/creativeorange-gravatar)[lasserafn/php-initial-avatar-generator

A package to generate avatars with initials for PHP

4374.2M13](/packages/lasserafn-php-initial-avatar-generator)[yzalis/identicon

Generate unique identicon avatars from any string

5901.1M21](/packages/yzalis-identicon)[ottaviano/faker-gravatar

Faker Gravatar image provider

1055.7k6](/packages/ottaviano-faker-gravatar)[irazasyed/laravel-identicon

Laravel Identicon Package

2329.5k1](/packages/irazasyed-laravel-identicon)

PHPackages © 2026

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