PHPackages                             phalcon/incubator-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. [Framework](/categories/framework)
4. /
5. phalcon/incubator-avatar

ActiveLibrary[Framework](/categories/framework)

phalcon/incubator-avatar
========================

Phalcon Incubator Avatar Adapters

v1.0.0(5y ago)533[1 PRs](https://github.com/phalcon/incubator-avatar/pulls)BSD-3-ClausePHPPHP &gt;=7.2

Since Oct 14Pushed 3y ago5 watchersCompare

[ Source](https://github.com/phalcon/incubator-avatar)[ Packagist](https://packagist.org/packages/phalcon/incubator-avatar)[ Docs](https://phalcon.io)[ GitHub Sponsors](https://github.com/phalcon)[ Fund](https://opencollective.com/phalcon)[ RSS](/packages/phalcon-incubator-avatar/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (7)Versions (4)Used By (0)

Phalcon\\Incubator\\Avatar
==========================

[](#phalconincubatoravatar)

[![Discord](https://camo.githubusercontent.com/28c6fc95b5decf0e67719a5438501589c00b2db2b15228e67479d6548bbc9f6b/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3331303931303438383135323337353239373f6c6162656c3d446973636f7264)](http://phalcon.io/discord)[![Packagist Version](https://camo.githubusercontent.com/043438b32f137f3a1f43d4c7547cb0e4968f46e18b8b4e142fc85eb3f655e01c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068616c636f6e2f696e63756261746f722d617661746172)](https://packagist.org/packages/phalcon/incubator-avatar)[![PHP from Packagist](https://camo.githubusercontent.com/b377762a16f7ccc672363fbc53dde615261ecb9e68b350b86689d3ce4bedf5e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068616c636f6e2f696e63756261746f722d617661746172)](https://packagist.org/packages/phalcon/incubator-avatar)[![codecov](https://camo.githubusercontent.com/7ad876312b3a2719a290547062e2661a65a2069afb6d9c66c76ee100b6b3e570/68747470733a2f2f636f6465636f762e696f2f67682f7068616c636f6e2f696e63756261746f722d6176617461722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/phalcon/incubator-avatar)[![Packagist](https://camo.githubusercontent.com/d399ad000a642a8a0fa29275c58b2be9fc618e176a8a55e9645bb77205034bb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f7068616c636f6e2f696e63756261746f722d617661746172)](https://packagist.org/packages/phalcon/incubator-avatar/stats)

Usage examples of the adapters available here:

Gravatar
--------

[](#gravatar)

[Gravatar's](http://gravatar.com/) are universal avatars available to all web sites and services. Users must register their email addresses with Gravatar before their avatars will be usable in your project.

### Getting Started

[](#getting-started)

#### Setup through setters

[](#setup-through-setters)

```
use Phalcon\Incubator\Avatar\Gravatar;

$di->setShared(
    'gravatar',
    function () {
        // Get Gravatar instance
        $gravatar = new Gravatar(
            []
        );

        // Setting default image, maximum size and maximum allowed Gravatar rating
        $gravatar->setDefaultImage('retro')
                 ->setSize(220)
                 ->setRating(Gravatar::RATING_PG);

        return $gravatar;
    }
);
```

#### Setup through config

[](#setup-through-config)

```
use Phalcon\Incubator\Avatar\Gravatar;

// Config must be either an array or \Phalcon\Config instance
$config = [
    'default_image' => 'mm',
    'rating'        => 'x',
    'size'          => 110,
    'use_https'     => true,
];

$di->setShared(
    'gravatar',
    function () use ($config) {
        // Get Gravatar instance
        $gravatar = new Gravatar($config);

        return $gravatar;
    }
);
```

### Using

[](#using)

```
// Get the Gravatar service from DI
$gravatar = $this->getDi()->getShared('gravatar');

// Build the Gravatar URL based on the configuration and provided email address
echo $gravatar->getAvatar('john@doe.com');
```

### Configuration

[](#configuration)

#### Gravatar size

[](#gravatar-size)

Gravatar allows avatar images ranging from 0px to 2048px in size. With using 0px size, images from Gravatar will be returned as 80x80px.

Example:

```
// Set gravatars size 64x64px
$gravatar->setSize(64);

// Set gravatars size 100x100px
$gravatar->setSize('100');
```

If an invalid size (less than 0, greater than 2048) or a non-integer value is specified, this method will throw an exception of class `\InvalidArgumentException`.

#### Default Image

[](#default-image)

Gravatar provides several pre-fabricated default images for use when the email address provided does not have a gravatar or when the gravatar specified exceeds your maximum allowed content rating. In addition, you can also set your own default image to be used by providing a valid URL to the image you wish to use.

There are a few conditions which must be met for default image URL:

- MUST be publicly available (e.g. cannot be on an intranet, on a local development machine, behind HTTP Auth or some other firewall etc). Default images are passed through a security scan to avoid malicious content
- MUST be accessible via HTTP or HTTPS on the standard ports, 80 and 443, respectively
- MUST have a recognizable image extension (jpg, jpeg, gif, png)
- MUST NOT include a query string (if it does, it will be ignored)

Possible values:

- `404` — do not load any image if none is associated with the email, instead return an HTTP 404 (File Not Found) response
- `mm` — (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email)
- `identicon` — a geometric pattern based on an email
- `monsterid` — a generated 'monster' with different colors, faces, etc
- `wavatar` — generated faces with differing features and backgrounds
- `retro` — awesome generated, 8-bit arcade-style pixelated faces
- `blank` — a transparent PNG image
- boolean false — if using the default gravatar image
- Image URL

Example:

```
// boolean false for the gravatar default
$gravatar->setDefaultImage(false);

// string specifying a recognized gravatar "default"
$gravatar->setDefaultImage('identicon');

// string with image URL
$gravatar->setDefaultImage('http://example.com/your-default-image.png');
```

If an invalid default image is specified (both an invalid prefab default image and an invalid URL is provided), this method will throw an exception of class `\InvalidArgumentException`.

#### Using secure connection

[](#using-secure-connection)

Should we use the secure (HTTPS) URL base? If your site is served over HTTPS, you'll likely want to serve gravatars over HTTPS as well to avoid "mixed content warnings".

Example:

```
// Enable secure connections:
$gravatar->enableSecureURL();

// Disable secure connections:
$gravatar->disableSecureURL();
```

To check to see if you are using "secure images" mode, call the method `Gravatar::isUseSecureURL()`, which will return a boolean value regarding whether or not secure images mode is enabled.

#### Gravatar Rating

[](#gravatar-rating)

Gravatar provides four levels for rating avatars by, which are named similar to entertainment media ratings scales used in the United States.

Possible values:

- `Gravatar::RATING_G` — suitable for display on all websites with any audience type
- `Gravatar::RATING_PG` — may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence
- `Gravatar::RATING_R` — may contain such things as harsh profanity, intense violence, nudity, or hard drug use
- `Gravatar::RATING_X` — may contain hardcore sexual imagery or extremely disturbing violence

By default, the Gravatar rating is `Gravatar::RATING_G`.

Example:

```
$gravatar->setRating(
    Gravatar::RATING_PG
);
```

If an invalid maximum rating is specified, this method will throw an exception of class `\InvalidArgumentException`.

#### Force Default

[](#force-default)

If for some reason you wanted to force the default image to always load, you can enable or disable it.

Example:

```
// Enable
$gravatar->enableForceDefault();

// Disable
$gravatar->disableForceDefault();
```

To check to see if you are using "Force Default" mode, call the method `Gravatar::isUseForceDefault()`, which will return a boolean value.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~360 days

Total

2

Last Release

1672d ago

Major Versions

v1.0.0 → v2.x-dev2021-10-10

### Community

Maintainers

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

---

Top Contributors

[![Jeckerson](https://avatars.githubusercontent.com/u/3289702?v=4)](https://github.com/Jeckerson "Jeckerson (3 commits)")[![jenovateurs](https://avatars.githubusercontent.com/u/3491729?v=4)](https://github.com/jenovateurs "jenovateurs (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (1 commits)")

---

Tags

avatargravatarphalconphpframeworkphalcongravataravatarincubator

###  Code Quality

TestsCodeception

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phalcon/incubator

Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.

7222.9M81](/packages/phalcon-incubator)[phalcon/devtools

This tools provide you useful scripts to generate code helping to develop faster and easy applications that use with Phalcon framework.

1.3k2.0M54](/packages/phalcon-devtools)[phalcon/migrations

Run and Generate DB Migrations with Phalcon Framework

29977.8k6](/packages/phalcon-migrations)[phalcon/incubator-mailer

Phalcon Incubator Mailer Adapters

1318.1k2](/packages/phalcon-incubator-mailer)

PHPackages © 2026

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