PHP code example of jairocgr / datashot

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

    

jairocgr / datashot example snippets


return [

  'database_servers' => [

    // A database server called 'live1'
    'live1' => [
      // Only mysql for now, maby postgres in the future
      'driver'   => 'mysql',

      // The env function will read from the environment or .env file
      'socket'   => env('MYSQL56_SOCKET', ''),
      'host'     => env('MYSQL56_HOST', 'localhost'),
      'port'     => env('MYSQL56_PORT', 3306),

      'user'     => env('MYSQL56_USER', 'root'),
      'password' => env('MYSQL56_PASSWORD', 'root'),

      // If you mark it as a 'production' server, a confirmation question
      // will be pronted in every execution and no drop action will
      // be performed for safety reasons
      'production' => TRUE
    ]
  ]
];

return [

  'repositories' => [
    'local' => [
      'driver' => 'fs',
      'path' => __DIR__ . '/snaps' // Local snaps directory
    ],

    'remote' => [
      'driver'     => 's3',
      'bucket'     => env('S3_BUCKET'),
      'region'     => env('S3_REGION'),
      // 'profile'    => 'remote',
      'access_key' => env('S3_ACESS_KEY'),
      'secret_key' => env('S3_SECRET_ACESS_KEY'),
      'base_path'  => 'snaps' // Remote path will be like s3://bucket-name/snaps
    ],
  ],

];

return [

  'snappers' => [
     'quick' => [

       // If you want to snap the rows only
       // 'data_only' => TRUE,

       // If you wanna dump only the ddl, triggers, functions, etc.
       // 'no_data' => TRUE,

       // Custom made user-defined property for later interpolation
       'cutoff' => '(NOW() - INTERVAL 3 MONTH)',

       // Table-specific where used to filter the rows witch will be dumped
       'wheres' => [

         // Interpolate the 'cutoff' parameter in the where clause for the
         // "logs" table
         'logs' => "created_at > '{cutoff}'",

         // Bring only the active users
         'users' => 'active = TRUE',
       ],

     ]
  ]

];