Synchronize your local or stage database with the production one.
ldavidsp/laravel-sync is a Laravel package for synchronize your local or stage database with the production one..
It currently has 3 GitHub stars and 282 downloads on Packagist (latest version v2.0.1).
Install it with composer require ldavidsp/laravel-sync.
Discover more Laravel packages by ldavidsp
or browse all Laravel packages to compare alternatives.
Last updated
This package contains some useful Artisan commands to work the synchronization of the local database with the production one.
This package requires Laravel 6 or newer.
You can install the package via Composer:
composer require ldavidsp/laravel-sync
Publish the config file with:
php artisan vendor:publish --tag=sync-config
Add tables to synchronize in config/sync.php:
/*
|--------------------------------------------------------------------------
| Sync tables
|--------------------------------------------------------------------------
*/
'sync_tables' => [
'table_name_1',
],
Add the configuration for the production database to config/database.php:
'live-db' => [
'driver' => env('DB_LIVE_CONNECTION', 'mysql'),
'host' => env('DB_LIVE_HOST', 'your live server database host here'),
'port' => env('DB_LIVE_PORT', '3306'),
'database' => env('DB_LIVE_DATABASE', 'forge'),
'username' => env('DB_LIVE_USERNAME', 'forge'),
'password' => env('DB_LIVE_PASSWORD', ''),
],
Add the configuration in .env:
DB_LIVE_CONNECTION=mysql
DB_LIVE_HOST=
DB_LIVE_PORT=3306
DB_LIVE_DATABASE=
DB_LIVE_USERNAME=
DB_LIVE_PASSWORD=
Synchronize database:
php artisan sync:prod
or
Add the configuration in app/Console/Kernel.php:
/**
* Sync local database with production.
*/
if (App::environment('local')) {
$schedule->command('sync:prod')->everyTenMinutes();
}
The MIT License (MIT). Please see License File for more information.