PHPackages                             vitaly-alexandrovich/yii2-json-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. vitaly-alexandrovich/yii2-json-behavior

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

vitaly-alexandrovich/yii2-json-behavior
=======================================

json behavior

1.0.1(7y ago)019PHP

Since May 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/vitaly-alexandrovich/yii2-json-behavior)[ Packagist](https://packagist.org/packages/vitaly-alexandrovich/yii2-json-behavior)[ RSS](/packages/vitaly-alexandrovich-yii2-json-behavior/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Поведение (behavior) для Yii2 позволяет удобно взаимодействовать с данными из json строки одной модели (родительской) через использование другой (обертки для данных).

Установка
=========

[](#установка)

Выполните команду в теминале

```
> composer require "vitaly-alexandrovich/yii2-json-behavior"
```

или добавьте

```
"vitaly-alexandrovich/yii2-json-behavior": "~1.0.1"
```

в секцию `require` файла `composer.json` в Вашем проекте

Использование
=============

[](#использование)

```
// Создаем модель для данных
class UserContacts extends \yii\base\Model
{
    public $phone;
    public $email;
    public $skype;
}

// В существующей ActiveRecord модели используем поведение JsonBehavior
class User extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return '{{%user}}';
    }

    public function behaviors()
    {
        return [
            // Указываем колонку с данными и модель для них
            \yii\behaviors\JsonBehavior::bind('contacts', UserContacts::class),
        ];
    }
}
```

Теперь мы можем читать данные:

```
    $user = User::findOne(1);

    $user->contacts->phone;
    $user->contacts->email;
    $user->contacts->skype;
```

И менять их:

```
    $user = User::findOne(1);

    $user->contacts->phone = '+7 (111) 222-33-44';
    $user->contacts->email = 'user@examle.com';
    $user->contacts->skype = 'user';

    $user->save();
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2611d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11419996?v=4)[Vitaly Dubovik](/maintainers/vitaly-alexandrovich)[@vitaly-alexandrovich](https://github.com/vitaly-alexandrovich)

---

Top Contributors

[![vitaly-alexandrovich](https://avatars.githubusercontent.com/u/11419996?v=4)](https://github.com/vitaly-alexandrovich "vitaly-alexandrovich (16 commits)")

### Embed Badge

![Health badge](/badges/vitaly-alexandrovich-yii2-json-behavior/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)

PHPackages © 2026

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