PHPackages                             tugmaks/yii2-creator-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. [Framework](/categories/framework)
4. /
5. tugmaks/yii2-creator-behavior

ActiveYii2-extension[Framework](/categories/framework)

tugmaks/yii2-creator-behavior
=============================

Creator behavior for Yii2

0269

Since May 30Compare

[ Source](https://github.com/tugmaks/yii2-creator-behavior)[ Packagist](https://packagist.org/packages/tugmaks/yii2-creator-behavior)[ RSS](/packages/tugmaks-yii2-creator-behavior/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 creator behavior
=====================

[](#yii2-creator-behavior)

Creator behavior for Yii2

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist tugmaks/yii2-creator-behavior "*"

```

or add

```
"tugmaks/yii2-creator-behavior": "*"

```

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

Usage
-----

[](#usage)

CreatorBehavior automatically fills the specified attributes with the current user id.

To use CreatorBehavior, insert the following code to your ActiveRecord class:

```
  use tugmaks\behaviors\CreatorBehavior;

  public function behaviors()
  {
      return [
          CreatorBehavior::className(),
      ];
  }
```

By default, CreatorBehavior will fill the `created_by` and `updated_by` attributes with the current user id when the associated AR object is being inserted; it will fill the `updated_by` attribute with the current user id when the AR object is being updated. The user id value is obtained by `Yii::$app->user->id`.

For the above implementation to work with MySQL database, please declare the columns(`created_by`, `updated_by`) as int(11).

If your attribute names are different or you want to use a different way of retrieving user id, you may configure the \[\[createdByAttribute\]\], \[\[updatedByAttribute\]\] and \[\[value\]\] properties like the following:

```
  public function behaviors()
  {
      return [
          [
              'class' => CreatorBehavior::className(),
              'createdByAttribute' => 'creator_id',
              'updatedByAttribute' => 'updater_id',
              'value'=>function($event){
                   return \Yii::$app->user->identity->getCustomId();
               }
          ],
      ];
  }
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

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

---

Top Contributors

[![tugmaks](https://avatars.githubusercontent.com/u/3036462?v=4)](https://github.com/tugmaks "tugmaks (3 commits)")

### Embed Badge

![Health badge](/badges/tugmaks-yii2-creator-behavior/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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