PHP code example of davmixcool / php-dbcloud

1. Go to this page and download the library: Download davmixcool/php-dbcloud 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/ */

    

davmixcool / php-dbcloud example snippets


//config/database.php

return [

    'development' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        // If singleTransaction is set to true, the --single-transcation flag will be set.
        'singleTransaction' => false,
        // Do not dump the given tables
        // Set only table names, without database name
        // Example: ['table1', 'table2']
        // http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_ignore-table
        'ignoreTables' => [],
        // using ssl to connect to your database - active ssl-support (mysql only):
        'ssl'=>false,
        // add additional options to dump-command (like '--max-allowed-packet')
        'extraParams'=>null,
    ],
    'production' => [
        'type' => 'postgresql',
        'host' => 'localhost',
        'port' => '5432',
        'user' => 'postgres',
        'pass' => 'password',
        'database' => 'test',
    ],
]

// config/storage.php
return [

    'local' => [
        'type' => 'Local',
        'root' => '/path/to/working/directory',
     ],
    's3' => [
        'type' => 'AwsS3',
        'key'    => '',
        'secret' => '',
        'region' => 'us-east-1',
        'version' => 'latest',
        'bucket' => '',
        'root'   => '',
    ],
    'gcs' => [
        'type' => 'Gcs',
        'key'    => '',
        'secret' => '',
        'version' => 'latest',
        'bucket' => '',
        'root'   => '',
    ],
    'dropbox-v2' => [
        'type' => 'DropboxV2',
        'token' => '',
        'key' => '',
        'secret' => '',
        'app' => '',
        'root' => '',
    ],
    'dropbox-v1' => [
        'type' => 'DropboxV1',
        'token' => '',
        'key' => '',
        'secret' => '',
        'app' => '',
        'root' => '',
     ],
    'ftp' => [
        'type' => 'Ftp',
        'host' => '',
        'username' => '',
        'password' => '',
        'root' => '',
        'port' => 21,
        'passive' => true,
        'ssl' => true,
        'timeout' => 30,
    ],
    'sftp' => [
        'type' => 'Sftp',
        'host' => '',
        'username' => '',
        'password' => '',
        'root' => '',
        'port' => 21,
        'timeout' => 10,
        'privateKey' => '',
    ],
]


use PhpDbCloud\Config\Config;
use PhpDbCloud\Filesystems;
use PhpDbCloud\Databases;
use PhpDbCloud\Compressors;
use PhpDbCloud\Sync;

// build providers
$filesystems = new Filesystems\FilesystemProvider(Config::fromPhpFile('config/storage.php'));
$filesystems->add(new Filesystems\Awss3Filesystem); 
$filesystems->add(new Filesystems\GcsFilesystem); 
$filesystems->add(new Filesystems\DropboxV1Filesystem); 
$filesystems->add(new Filesystems\DropboxV2Filesystem); 
$filesystems->add(new Filesystems\FtpFilesystem); 
$filesystems->add(new Filesystems\LocalFilesystem);
$filesystems->add(new Filesystems\SftpFilesystem); 

$databases = new Databases\DatabaseProvider(Config::fromPhpFile('config/database.php'));
$databases->add(new Databases\MysqlDatabase);
$databases->add(new Databases\PostgresqlDatabase);

$compressors = new Compressors\CompressorProvider;
$compressors->add(new Compressors\GzipCompressor);
$compressors->add(new Compressors\NullCompressor);

// build sync
return new Sync($filesystems, $databases, $compressors);


use PhpDbCloud\Filesystems\Destination;

$sync = tination('dropbox-v2', 'test/backup.sql')], 'gzip');

$sync = makeRestore()->run('dropbox-v2', 'test/backup.sql.gz', 'development', 'gzip');
shell
composer