yii2mod/yii2-data-sync-behavior Behavior for export data to local files from database tables. Changes are tracked using model events.

yii2export

Yii2 data synchronization behavior

Behavior for export data to local files from database tables. Changes are tracked using model events.

Latest Stable Version Total Downloads License Build Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2mod/yii2-data-sync-behavior "*"

or add

"yii2mod/yii2-data-sync-behavior": "*"

to the require section of your composer.json file.

Recording changes

Attach the behavior to the model:

use yii2mod\datasync\DataSyncBehavior;

public function behaviors()
{
    return [
        'dataSync' => [
            'class' => DataSyncBehavior::className(),
            // `folderPath` property maybe need to change.
            'folderPath' => '@app/config/data'
        ],
    ];
}
  • After model events(AFTER_UPDATE, AFTER_INSERT, AFTER_DELETE) behavior will be automatically create files in default path(@app/config/data) with data from this model.
  • Files will be created in json format.

Import changes

  1. Add datasync command to console config:

    'controllerMap' => [
        'datasync' =>  [
            'class' => 'yii2mod\datasync\commands\DataSyncCommand',
            // `folderPath` property maybe need to change.
            'folderPath' => '@app/config/data'
        ],
    ],
  2. Execute command from console. For example:

    php yii datasync - synchronize data for all files
    php yii datasync/index --table=User - synchronize data only for `User` table

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

  • 1.322 November 2016
  • 1.207 July 2016
  • 1.129 June 2016
  • 1.031 August 2015

Comments



1.3 is the latest of 4 releases



MIT license
Stats
4 github stars & 2 github forks
0 downloads in the last day
1 downloads in the last 30 days
134 total downloads