Behavior for export data to local files from database tables. Changes are tracked using model events.
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.
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'
],
];
}
Add datasync
command 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
Comments