sam-it/yii2-jsonbehavior
This package is abandoned and no longer maintained.
No replacement package was suggested.
Advanced AR JSON support
Maintainers
v2.0.0
2020-06-01 11:26 UTC
Requires
- php: > 7.4
- ext-json: *
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- phpunit/phpunit: ^9.1
- squizlabs/php_codesniffer: ^3.5
- yiisoft/yii2: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 528415787ce35137e8da1df98a44570d5d7fdc94
- Sam Mousa <sam.woop@mousa.nl>
- Joey Claessen <joey_claessen.woop@hotmail.com>
This package is auto-updated.
Last update: 2026-04-25 21:56:15 UTC
README
👁 Scrutinizer Code Quality
👁 Code Coverage
👁 Build Status
👁 Total Downloads
👁 Latest Stable Version
Yii2 JsonBehavior
Work with JSON fields in Yii2
This behavior adds advanced support for working with JSON data in Yii AR models.
Use JSON fields like normal fields
Consider a model having a data attribute that is stored as JSON.
public function behaviors() {
return [
['class' => JsonBehavior::class, 'jsonAttributes' => ['data']]
];
}
// Examples:
$model = new Model();
$model->a = "test"; // If attribute 'a' does not exist this is stored inside the data.
$model->a['b'] = 'c']; // Nested arrays are supported.
$model->data = ['x' => 'y']; // Assigning directly is supported.
