PHPackages                             brussens/yii2-avatar-behavior - 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. brussens/yii2-avatar-behavior

ActiveYii2-behavior

brussens/yii2-avatar-behavior
=============================

Behavior for the transparent operations of avatar thumbnails

0.1.0(10y ago)1114MITPHP

Since Nov 15Pushed 10y agoCompare

[ Source](https://github.com/brussens/yii2-avatar-behavior)[ Packagist](https://packagist.org/packages/brussens/yii2-avatar-behavior)[ Docs](https://github.com/brussens/yii2-avatar-behavior)[ RSS](/packages/brussens-yii2-avatar-behavior/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

\#Yii2 avatar behavior Behavior for the transparent operations of avatar thumbnails

[![Latest Stable Version](https://camo.githubusercontent.com/686effa71eddfd4c55082562c150078d9ba9f0101312a72d456ee69d6d86d1dc/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d6176617461722d6265686176696f722f762f737461626c65)](https://packagist.org/packages/brussens/yii2-avatar-behavior)[![Total Downloads](https://camo.githubusercontent.com/7d4a4f56418c2ca4a5ed56a467d1e6fc5291d3e2c80e5e12af36dfd4698d8b6d/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d6176617461722d6265686176696f722f646f776e6c6f616473)](https://packagist.org/packages/brussens/yii2-avatar-behavior)[![License](https://camo.githubusercontent.com/b942487731fcff117e23df511a4b7285f58ad19d0f617c67d797368fc4badc6e/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d6176617461722d6265686176696f722f6c6963656e7365)](https://packagist.org/packages/brussens/yii2-avatar-behavior)

\##Install Either run

```
php composer.phar require --prefer-dist brussens/yii2-avatar-behavior "*"

```

or add

```
"brussens/yii2-avatar-behavior": "*"

```

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

\##Model configurations Add a new attribute to the user's model, such as "userpic"

Add to your user model:

```
namespace common\models;

use yii\db\ActiveRecord;
use brussens\behaviors\AvatarBehavior;

class User extends ActiveRecord
{
    public static function tableName()
    {
        return '{{%user}}';
    }

    public function behaviors()
    {
        return [
            'avatarBehavior' => [
                'class' => AvatarBehavior::className(),
                'attribute' => 'userpic'
            ]
        ];
    }
}
```

Use
---

[](#use)

```
//Returns user avatar as Html::img()
echo Yii::$app->getUser()->getIdentity()->getThumb(30, 30, [
    'class' => 'img-thumbnail'
]);

//Returns user avatar url
echo Html::img(Yii::$app->getUser()->getIdentity()->getThumbUrl(30, 30));

//Some user
$user = User::findOne(1);
echo $user->getThumb(20, 20);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3831d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/436a63d75811386f486820ea2de0060dc20d95294beee6555edf6ea7c03bc367?d=identicon)[brussens](/maintainers/brussens)

---

Tags

yii2Behavioravataryii 2

### Embed Badge

![Health badge](/badges/brussens-yii2-avatar-behavior/health.svg)

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

###  Alternatives

[softark/yii2-dual-listbox

Bootstrap Dual Listbox Widget for Yii 2

20144.4k11](/packages/softark-yii2-dual-listbox)[oxyaction/yii2-polymorphic-relation-behavior

Establishes polymorphic relations

1125.3k](/packages/oxyaction-yii2-polymorphic-relation-behavior)[zertex/yii2-avatar-generator

Avatar generator for Yii2 Framework.

104.5k1](/packages/zertex-yii2-avatar-generator)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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