PHPackages                             shoormax/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. shoormax/gravatar

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

shoormax/gravatar
=================

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

v2.0.0(7y ago)08MITPHPPHP ^7.1

Since Jun 14Pushed 6y agoCompare

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

READMEChangelogDependencies (1)Versions (5)Used By (0)

Gravatar
========

[](#gravatar)

[![Latest Version](https://camo.githubusercontent.com/abf05fee4428bd456fd643ac112b00433640af151f35d9054cd4bcc8b0c681a0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://github.com/gravatarphp/gravatar/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/0437395ddf0ff4cda98651d530be6e85760424ff3ce11a8c1b6ded37240d3368/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gravatarphp/gravatar)[![Code Coverage](https://camo.githubusercontent.com/d7c08f47f1e78072e1cfadee5d24cb66aff6fabc0ceabfab0e40cd32ffbd09b4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gravatarphp/gravatar)[![Quality Score](https://camo.githubusercontent.com/1736846a77b80662c240c48f2673e4ba6e23ae9d5af11acde4472b10eaa52048/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gravatarphp/gravatar)[![Total Downloads](https://camo.githubusercontent.com/f026f98cf550380efbe851d02cc268b4570a213b19374a44ccf14803bc8cfc1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726176617461727068702f67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gravatarphp/gravatar)

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

Install
-------

[](#install)

Via Composer

```
$ composer require shoormax/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
```

Credits
-------

[](#credits)

- [Márk Sági-Kazár](https://github.com/sagikazarmark)
- [All Contributors](https://github.com/gravatarphp/gravatar/contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

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

2679d 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/ec1e134b2a9f49777ac5993d7d7208115367334dc53c5e751ebc3c8ad4dbfd52?d=identicon)[Shosho](/maintainers/Shosho)

---

Top Contributors

[![sagikazarmark](https://avatars.githubusercontent.com/u/1226384?v=4)](https://github.com/sagikazarmark "sagikazarmark (24 commits)")[![Shoormax](https://avatars.githubusercontent.com/u/22323027?v=4)](https://github.com/Shoormax "Shoormax (4 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (3 commits)")[![sprak3000](https://avatars.githubusercontent.com/u/5545555?v=4)](https://github.com/sprak3000 "sprak3000 (1 commits)")

---

Tags

imageprofilegravataravatar

### Embed Badge

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

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

###  Alternatives

[laravolt/avatar

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

2.0k5.4M31](/packages/laravolt-avatar)[multiavatar/multiavatar-php

Multicultural Avatar Generator

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

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

16625.8k2](/packages/gravatarphp-gravatar)[arcanedev/gravatar

A library providing easy gravatar integration/generation (Laravel supported).

1986.8k](/packages/arcanedev-gravatar)[artdarek/avatarer

Avatarer - Social media avatars for Laravel 5

1015.4k](/packages/artdarek-avatarer)[ottaviano/faker-gravatar

Faker Gravatar image provider

1055.7k6](/packages/ottaviano-faker-gravatar)

PHPackages © 2026

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