PHPackages                             consultnn/yii2-behaviors - 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. consultnn/yii2-behaviors

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

consultnn/yii2-behaviors
========================

1.0.3(10y ago)1951MITPHPPHP &gt;=5.4.0

Since Jul 22Pushed 8y ago13 watchersCompare

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

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

\[We no longer maintain this repository\]
-----------------------------------------

[](#we-no-longer-maintain-this-repository)

Use [consultnn/yii2-validators](https://github.com/consultnn/yii2-validators) instead AttributeTypeBehavior

yii2-behaviors
==============

[](#yii2-behaviors)

Extension of the class [yii\\base\\Behavior](https://github.com/yiisoft/yii2/blob/master/framework/base/Behavior.php)

---

\###Class **AttributeTypeBehavior** to converts attribute for all simple [types](https://github.com/yiisoft/yii2/blob/master/framework/base/Behavior.php) and mongoDb types.
Number and boolean type taken from the corresponding attribute validator

##### Example of a call from the model.

[](#example-of-a-call-from-the-model)

```
    public function behaviors()
    {
        return [
            [
                'class' => AttributeTypeBehavior::className(),
                'attributes' => [
                    '_id' => AttributeTypeBehavior::TYPE_MONGO_ID,
                    'attribute1' => [AttributeTypeBehavior::TYPE_ARRAY_OF => AttributeTypeBehavior::TYPE_INTEGER]
                ]
            ]
        ];
    }
```

Default events `ActiveRecord::EVENT_BEFORE_INSERT`, `ActiveRecord::EVENT_BEFORE_UPDATE`

##### Example add convert MongoDate type.

[](#example-add-convert-mongodate-type)

Add `attributes => ['date' => 'MongoDate']`
Add a method to the class AttributeTypeBehavior:

```
    private function setMongoDate(&$value)
    {
        $value = new \MongoDate(strtotime($value));
    }
```

---

\###Class **TreeViewBehavior** to dynamically update the model attributes with the use of plug-in [jstree](https://github.com/vakata/jstree)Events `ActiveRecord::EVENT_BEFORE_INSERT`, `ActiveRecord::EVENT_BEFORE_UPDATE`, `ActiveRecord::EVENT_BEFORE_DELETE`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

4

Last Release

3717d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6559f1e755ff5770d012bdedb22e589553caabaf3a78eadfa944d832ce16eef2?d=identicon)[sokrat](/maintainers/sokrat)

---

Top Contributors

[![sokrat](https://avatars.githubusercontent.com/u/427543?v=4)](https://github.com/sokrat "sokrat (23 commits)")[![aciden](https://avatars.githubusercontent.com/u/8599812?v=4)](https://github.com/aciden "aciden (21 commits)")[![avalonNN](https://avatars.githubusercontent.com/u/13140158?v=4)](https://github.com/avalonNN "avalonNN (10 commits)")[![serieznyi](https://avatars.githubusercontent.com/u/2323142?v=4)](https://github.com/serieznyi "serieznyi (10 commits)")[![St1Gz](https://avatars.githubusercontent.com/u/1092433?v=4)](https://github.com/St1Gz "St1Gz (2 commits)")

---

Tags

not-support

### Embed Badge

![Health badge](/badges/consultnn-yii2-behaviors/health.svg)

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

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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