PHPackages                             budipratama/yii2-userbehaviors - 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. budipratama/yii2-userbehaviors

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

budipratama/yii2-userbehaviors
==============================

User Behaviors

17PHP

Since Aug 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/budipratama/yii2-userbehaviors)[ Packagist](https://packagist.org/packages/budipratama/yii2-userbehaviors)[ RSS](/packages/budipratama-yii2-userbehaviors/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

User Behaviors
==============

[](#user-behaviors)

User Behaviors

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist budipratama/yii2-userbehaviors "@dev"

```

or add

```
"budipratama/yii2-userbehaviors": "@dev"

```

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

Usage
-----

[](#usage)

UserBehaviors automatically fills the specified attributes with the current username login. To use UserBehaviors, insert the following code your ActiveRecord class:

```
use budipratama\behaviors\UserBehaviors;

 public function behaviors()
 {
     return [
           [
               'class' => UserBehaviors::class
           ],
     ];
 }
```

By default, UserBehaviors will fill the first\_user and last\_user attributes with the current username when created row the associated AR object is being inserted. it will fill the last\_user attribute with the username when the AR object is being updated. The user value is obtained by username. Because attribute values will be set automatically by this behavior, they are usually not user input and should therefore not be validated, i.e. first\_user and last\_user should not appear in the rules() method of the model. For the above implementation to work with MySQL database, please declare the columns(first\_user, last\_user) as varchar(50). If your attribute names are different, you may configure the $createdAtAttribute, $updatedAtAttribute and $value properties like the following:

```
 public function behaviors()
 {
     return [
           [
               'class' => UserBehaviors::class,
               'createdAtAttribute' => 'first_userid',
               'updatedAtAttribute' => 'last_userid',
               'value' => function(){
                   return \Yii::$app->user->id;
               }
           ],
     ];
 }
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cfbc55411a4bf79e678278098bb7d3cc62705632e7d62d84c37ba76c16e02bf?d=identicon)[budipratama](/maintainers/budipratama)

### Embed Badge

![Health badge](/badges/budipratama-yii2-userbehaviors/health.svg)

```
[![Health](https://phpackages.com/badges/budipratama-yii2-userbehaviors/health.svg)](https://phpackages.com/packages/budipratama-yii2-userbehaviors)
```

PHPackages © 2026

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