PHP code example of emidia / yii2-jsonify

1. Go to this page and download the library: Download emidia/yii2-jsonify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

emidia / yii2-jsonify example snippets


use emidia\yii2\JsonifyBehavior;
public function behaviors()
{
    return [
        JsonifyBehavior::className(),
    ];
}

public function behaviors()
{
    return [
        [
            'class' => JsonifyBehavior::className(),
            'attribute' => 'data',
        ],
    ];
}

$model->setAttributes([
  'data' => [
    'id'=> 12,
    'title' => 'test'
  ]
]);