sam-it / yii2-jsonbehavior
Advanced AR JSON support
Installs: 18 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 10
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
- dev-master
- v2.0.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/node-fetch-2.6.7
- dev-dependabot/npm_and_yarn/semantic-release-19.0.3
- dev-dependabot/npm_and_yarn/minimist-1.2.6
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/glob-parent-5.1.2
- dev-dependabot/npm_and_yarn/normalize-url-5.3.1
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/ini-1.3.8
This package is auto-updated.
Last update: 2024-11-25 18:35:51 UTC
README
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.