PHP code example of amitdugar / db-tools
1. Go to this page and download the library: Download amitdugar/db-tools 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/ */
amitdugar / db-tools example snippets
return [
'default' => [
'host' => 'localhost',
'database' => 'myapp',
'user' => 'root',
'password' => 'secret',
],
'analytics' => [
'host' => 'localhost',
'database' => 'analytics_db',
'user' => 'root',
'password' => 'secret',
],
];
// db-tools.php - shared project config
return [
'default' => [
'host' => $_ENV['DB_HOST'] ?? 'localhost',
'port' => (int) ($_ENV['DB_PORT'] ?? 3306),
'database' => $_ENV['DB_DATABASE'],
'user' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'output_dir' => __DIR__ . '/backups',
'retention' => 7,
'compression' => 'zstd',
],
];
// db-tools.local.php - local dev overrides (add to .gitignore)
return [
'default' => [
'host' => '127.0.0.1',
'database' => 'myapp_dev',
'user' => 'root',
'password' => 'localpass',
],
];
// db-tools.php
return [
'default' => [
// ...
'encryption_password' => getenv('BACKUP_ENCRYPTION_KEY'),
],
];