Yii2 Dumpling
, (*1)
Yii2 Dumpling is a simple Yii2 extension for dumping and restoring databases., (*2)
Installation
Install extension with Composer:, (*3)
composer require "herroffizier/yii2-dumpling:@stable"
Update your app config:, (*4)
// Add module to bootstrap
'bootstrap' => [
// ...
'dumpling',
// ...
],
// Add module to app
'modules' => [
// ...
'dumpling' => [
'class' => 'herroffizier\yii2dumpling\Module',
],
// ...
],
And you're done., (*5)
Usage
Currently only MySQL databases are supported., (*6)
API
To dump database:, (*7)
Yii::$app->dumpling->dump();
To restore database:, (*8)
Yii::$app->dumpling->restore();
By default Dumpling uses db
as database component and @app/runtime/dump.sql
as dump file name. These values may be customized either by module config or by method arguments. Refer to source code for details., (*9)
In case of error yii\base\Exception
will be thrown., (*10)
Console
You also may use Dumpling in a console., (*11)
To dump:, (*12)
php yii dumpling/dump
To restore:, (*13)
php yii dumpling/restore
Both commands supports --file
and --db
options for setting dump file name and database component accordingly., (*14)