PHPackages                             lebedyncrs/yii2-attrswatcher - 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. lebedyncrs/yii2-attrswatcher

ActiveYii2-extension

lebedyncrs/yii2-attrswatcher
============================

Sometimes you want on change some attribute set value to another attribute. This extention provide that.

043PHP

Since Aug 8Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Attribute watcher for Yii2
==========================

[](#attribute-watcher-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 lebedyncrs/yii2-attrswatcher

```

or add

```
"lebedyncrs/yii2-attrswatcher": "*"
```

to the require section of your composer.json. Usage
---------------------------------------------------

[](#to-the-require-section-of-your-composerjsonusage)

Sometimes you want on change some attribute set value to another attribute. This behavior provide that.
Attach behavior to model:

```
public function behavior(){
  [
    'class' => AttrsWatcherBehavior::className(),
    'attributes' => [
          'Status' => [
              AttrsWatcherBehavior::ATTRIBUTE => 'ClosedOn',
              AttrsWatcherBehavior::FROM => null
              AttrsWatcherBehavior::TO => 1
            ],
            'Rel_DealStage' => [
                   AttrsWatcherBehavior::ATTRIBUTE => 'LastStageChange',
            ]
      ]
  ]
}
```

With this configuration behavior set current timestamp to `ClosedOn` attribute when `Status` will be changed from `null` to `1`. When `Rel_DealStage` will changed `LastStageChange` will containt current timestamp.

```
public function behavior(){
  [
    'class' => AttrsWatcherBehavior::className(),
    'attributes' => [
          'Status' => [
              AttrsWatcherBehavior::ATTRIBUTE => 'ClosedOn',
              AttrsWatcherBehavior::FROM => null
              AttrsWatcherBehavior::TO => 1
            ],
            'Rel_DealStage' => [
                   AttrsWatcherBehavior::ATTRIBUTE => 'LastStageChange',
            ]
      ],
      'values' => [
          'ClosedOn' => 'my own value',
          'LastStageChange' => 'my own value'
      ]
  ]
}
```

As you can see from above example you can set own value for each attribute.
Also you can change default value for all attributes:

```
public function behavior(){
  [
    'class' => AttrsWatcherBehavior::className(),
    'attributes' => [
          'Status' => [
              AttrsWatcherBehavior::ATTRIBUTE => 'ClosedOn',
          ]
      ],
      'values' => function(){
        return time()-100;
      }
  ]
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/lebedyncrs-yii2-attrswatcher/health.svg)

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

PHPackages © 2026

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