PHPackages                             zertex/yii2-avatar-generator - 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. zertex/yii2-avatar-generator

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

zertex/yii2-avatar-generator
============================

Avatar generator for Yii2 Framework.

1.1.7(3y ago)104.5k11BSD-3-ClausePHP

Since Jun 26Pushed 3y ago2 watchersCompare

[ Source](https://github.com/zertex/yii2-avatar-generator)[ Packagist](https://packagist.org/packages/zertex/yii2-avatar-generator)[ RSS](/packages/zertex-yii2-avatar-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (16)Used By (1)

Avatar Generator
================

[](#avatar-generator)

Generate avatar for user by his name, file or url for Yii2.

[![Latest Stable Version](https://camo.githubusercontent.com/b65d0fadff3de1bbc366f6fddb061452bc1be3dac615e3039323ad0cc1ddb3de/68747470733a2f2f706f7365722e707567782e6f72672f7a65727465782f796969322d6176617461722d67656e657261746f722f762f737461626c652e706e67)](https://packagist.org/packages/zertex/yii2-avatar-generator)[![Total Downloads](https://camo.githubusercontent.com/9e72de2828f303c3b82d36daaef135a98b2c155affe44b427c511768d79bfe36/68747470733a2f2f706f7365722e707567782e6f72672f7a65727465782f796969322d6176617461722d67656e657261746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/zertex/yii2-avatar-generator)

Features
--------

[](#features)

- Generate avatar by username
- Generate avatar from file or url (http only)
- Auto select background color by username
- Contrast color for text
- Font face and size customize
- Texture for background (2 available now)

Dependencies
------------

[](#dependencies)

- PHP 7
- PHP GD
- zertex/avatar-generator

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

[](#installation)

Install with composer:

```
composer require zertex/yii2-avatar-generator
```

or add

```
"zertex/yii2-avatar-generator": "*"
```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

Add to `common/config/main.php`or `config/web.php`

```
'components' => [
    ...
    'avatar' => [
        'class' => \zertex\avatar_generator\AvatarGenerator::class,
        'images_folder' => 'path_to_image_files',
        'images_url' => 'url_to_image_files',
        'size_width' => 300,            // default: 300
        'font' => 'path_to_ttf_font',   // default: Play-Bold // may use aliases
        'font_size' => 200,             // default: 200
        'salt' => 'random_salt',        // salt for image file names
        'texture' => ['sun', 'rain'],   // texture name
        'text_over_image' => true,      // draw text over image (for avatar from file)
        'texture_over_image' => true,   // draw texture over image (for avatar from file)
    ],
],
```

- images\_folder - `required` Folder for images
- images\_url - `required` Url to folder with images
- size\_width - Origin image side width. Default: 300
- font - Path to TTF font file. Yii2 aliases ready. Default: Play-Bold.ttf
- font\_size - Font size. Default: 300
- salt - Random garbage for images file name
- texture - Texture name: sun, rain. Default: empty
- text\_over\_image - Draw text over image. For avatar created from file. Default: true
- texture\_over\_image - Draw texture over image. For avatar created from file. Default: true

Using
-----

[](#using)

```
Yii::$app->avatar->show('username', [width], [file or url], [new_file_name]);

```

Simple use with default image resolution

```
avatar->show('John Smith') ?>
```

Image with 150 px sides

```
avatar->show('John Smith', 150) ?>
```

Image for existing file with default image resolution

```
avatar->show('John Smith', null, '/path/JM_Avatar.jpg') ?>
```

or

```
avatar->show('John Smith', null, 'http://site.org/JM_Avatar.jpg') ?>
```

Image for existing file with 150 px sides

```
avatar->show('John Smith', 150, '/path/JM_Avatar.jpg') ?>
```

#### Using without Yii2 wrap

[](#using-without-yii2-wrap)

You can use avatar generator without Yii2 wrap. Just install

Screenshot
----------

[](#screenshot)

[![alt text](https://camo.githubusercontent.com/c66bec5438361c2e9ad7d5e16400e5118452ef01763472640f998f4ab797ec0b/687474703a2f2f7a65727465782e72752f6578742d62616e6e6572332e706e67)](https://camo.githubusercontent.com/c66bec5438361c2e9ad7d5e16400e5118452ef01763472640f998f4ab797ec0b/687474703a2f2f7a65727465782e72752f6578742d62616e6e6572332e706e67)

Examples
--------

[](#examples)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

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

Recently: every ~422 days

Total

15

Last Release

1185d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23960eb78c22b402a0e26140a49a156c4eba9cccd637067010c7f33524a66f09?d=identicon)[Error202](/maintainers/Error202)

---

Top Contributors

[![zertex](https://avatars.githubusercontent.com/u/6353201?v=4)](https://github.com/zertex "zertex (25 commits)")

---

Tags

yii2avataryii 2avatar-generatoruserpic

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zertex-yii2-avatar-generator/health.svg)

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

###  Alternatives

[softark/yii2-dual-listbox

Bootstrap Dual Listbox Widget for Yii 2

20144.4k11](/packages/softark-yii2-dual-listbox)[vova07/yii2-start-comments-module

The comments module for Yii2-Start application.

159.5k1](/packages/vova07-yii2-start-comments-module)

PHPackages © 2026

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