yii2mod / yii2-data-sync-behavior
This package is abandoned and no longer maintained.
No replacement package was suggested.
Behavior for export data to local files from database tables. Changes are tracked using model events.
Package info
github.com/yii2mod/yii2-data-sync-behavior
Type:yii2-extension
pkg:composer/yii2mod/yii2-data-sync-behavior
1.3
2016-11-22 14:43 UTC
Requires
- php: >=5.5
- yiisoft/yii2: >=2.0.8
Requires (Dev)
This package is not auto-updated.
Last update: 2017-08-20 08:17:09 UTC
README
Behavior for export data to local files from database tables. Changes are tracked using model events.
[](https://packagist.org/packages
/yii2mod/yii2-data-sync-behavior)
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
- Add
datasynccommand to console config:
'controllerMap' => [
'datasync' => [
'class' => 'yii2mod\datasync\commands\DataSyncCommand',
// `folderPath` property maybe need to change.
'folderPath' => '@app/config/data'
],
],
-
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