PHPackages                             jberall/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. [Database &amp; ORM](/categories/database)
4. /
5. jberall/yii2-json-behavior

ActiveYii2-extension[Database &amp; ORM](/categories/database)

jberall/yii2-json-behavior
==========================

Attaches behavior for a Postgresql jsonb column

016PHP

Since May 16Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Json Behavior
=============

[](#json-behavior)

Attaches behavior for a Postgresql jsonb column

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist jberall/yii2-json-behavior "*"

```

or add

```
"jberall/yii2-json-behavior": "*"

```

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

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by: You need to identify the json\_attribute as your column in the database. Will check to see if model and attribute exist.

use jberall\\jsonbehavior;

```
//declare the variables.
//attributes.
public $some_attribute,$another_attribute;
//objects
public $dimension;
//arrayObjects.
public $emails, $phone_numbers;

public function behaviors() {

    $behaviors = [
        'attributeJsonBehavior' =>[
            'class' => JsonBehavior::className(),
            'attributes' => ['some_attribute'=>null, 'another_attribute'=>null],
            'json_attribute'=> 'data_json',
        ],
		'objectJsonBehavior' => [
            'class' => JsonBehavior::className(),
            'arrayObjects' => [
                'dimension'=>'\full\path\Dimension',

             ],
            'json_attribute'=> 'data_json',
        ],
        'arrayObjectsJsonBehavior' => [
            'class' => JsonBehavior::className(),
            'arrayObjects' => [
                'emails'=>\full\path\'Email',
                'phone_numbers'=>'\full\path\PhoneNumber',
             ],
            'json_attribute'=> 'data_json',
        ],

		//OR Combine into one.
		'namedBehavior' => [
            'class' => JsonBehavior::className(),
            'attributes' => ['some_attribute'=>null, 'another_attribute'=>null],
			'arrayObjects' => [
                'dimension'=>'\full\path\Dimension',

             ],
            'arrayObjects' => [
                'emails'=>\full\path\'Email',
                'phone_numbers'=>'\full\path\PhoneNumber',
             ],
            'json_attribute'=> 'data_json',
		],
    ];
    return ArrayHelper::merge(parent::behaviors(),$behaviors);

}

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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/b0e2e29d7fb708493437055490cbf0e58179b34a3a8f4a2760e7c50f618a0f7b?d=identicon)[jberall](/maintainers/jberall)

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)

PHPackages © 2026

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