PHP code example of beaten-sect0r / yii2-db-manager

1. Go to this page and download the library: Download beaten-sect0r/yii2-db-manager 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/ */

    

beaten-sect0r / yii2-db-manager example snippets


    'modules' => [
        'db-manager' => [
            'class' => 'bs\dbManager\Module',
            // path to directory for the dumps
            'path' => '@app/backups',
            // list of registerd db-components
            'dbList' => ['db'],
            // Flysystem adapter (optional) creocoder\flysystem\LocalFilesystem will be used as default. 
            'flySystemDriver' => 'creocoder\flysystem\LocalFilesystem',
            'as access' => [
                'class' => 'yii\filters\AccessControl',
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['admin'],
                    ],
                ],
            ],
        ],
    ],

    'components' => [
        // https://github.com/creocoder/yii2-flysystem
        'backupStorage' => [
            'class' => 'creocoder\flysystem\FtpFilesystem',
            'host' => 'ftp.example.com',
            //'port' => 21,
            //'username' => 'your-username',
            //'password' => 'your-password',
            //'ssl' => true,
            //'timeout' => 60,
            //'root' => '/path/to/root',
            //'permPrivate' => 0700,
            //'permPublic' => 0744,
            //'passive' => false,
            //'transferMode' => FTP_TEXT,
        ],
    ],
    'modules' => [
        'db-manager' => [
            'class' => 'bs\dbManager\Module',
            // Flysystem adapter (optional) creocoder\flysystem\LocalFilesystem will be used as default. 
            'flySystemDriver' => 'creocoder\flysystem\LocalFilesystem',
            // path to directory for the dumps
            'path' => '@app/backups',
            // list of registerd db-components
            'dbList' => ['db', 'db1', 'db2'],
            // process timeout
            'timeout' => 3600,
            // additional mysqldump/pg_dump presets (available for choosing in dump and restore forms)
            'customDumpOptions' => [
                'mysqlForce' => '--force',
                'somepreset' => '--triggers --single-transaction',
                'pgCompress' => '-Z2 -Fc',
            ],
            'customRestoreOptions' => [
                'mysqlForce' => '--force',
                'pgForce' => '-f -d',
            ],
            // options for full customizing default command generation
            'mysqlManagerClass' => 'CustomClass',
            'postgresManagerClass' => 'CustomClass',
            // option for add additional DumpManagers
            'createManagerCallback' => function($dbInfo) {
                if ($dbInfo['dbName'] == 'exclusive') {
                    return new MyExclusiveManager;
                } else {
                    return false;
                }
            }
            'as access' => [
                'class' => 'yii\filters\AccessControl',
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['admin'],
                    ],
                ],
            ],
        ],
    ],

    'modules' => [
        'db-manager' => [
            'class' => 'bs\dbManager\Module',
            // Flysystem adapter (optional) creocoder\flysystem\LocalFilesystem will be used as default. 
            'flySystemDriver' => 'creocoder\flysystem\LocalFilesystem',
            // path to directory for the dumps
            'path' => '@app/backups',
            // list of registerd db-components
            'dbList' => ['db'],
        ],
    ],
config/web.php
backend/config/main.php
index.php?r=db-manager
bash
php yii dump/create -db=db -gz -s
bash
php yii dump/restore -db=db -s -f=dump.sql
bash
php yii dump/delete-all
bash
php yii dump/test-connection -db=db