New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

toyi/sync-database

Sync your MySQL local database with a remote one.
9,938
Install
composer require toyi/sync-database
Latest Version:v2.1.0
PHP:>=8.1
Laravel:9 – 13
Older releases:5 – 8
License:MIT
Last Updated:Apr 26, 2026
Links: GitHub  ·  Packagist
Maintainer: toyi

Description

Use this package to synchronize your local development MySQL database with a remote one (e.g., production). It'll connect through SSH to a remote server, make a dump, download it and import it into your local MySQL database.

Prerequisites

Local environment

  • mysql binary (mysql --version)
  • GZip (gzip --version)

Remote environment

  • mysqldump binary (mysqldump --version)
  • GZip (gzip --version)

Limitations

  • This package only supports MySQL
  • It only supports databases hosted on the remote server you provided (local machine > remote machine > dump > local machine)

Installation

composer require toyi/sync-database

Before Laravel 5.5

After updating composer, add the SyncDatabaseProvider to the providers array in config/app.php Toyi\SyncDatabase\SyncDatabaseProvider::class,

Usage

You should publish the config/sync-database.php config file using php artisan vendor:publish --provider="Toyi\SyncDatabase\SyncDatabaseProvider".

The ssh part will be used to connect to your remote server.
The database part will be used to dump the remote database.

Once everything is configured, use php artisan toyi:sync-database.

Available options :

  • --tables-no-data A comma separated list of tables. Only their structure will be dumped (no data)
  • --no-migrations Don't execute pending migrations at the end.

The remote database will only be dumped, nothing will ever be written.

The temporary files are deleted once the dump process is over.
However, should something fail, they might persist (and take unecessary disk space). If this is the case, you can delete them yourself (they will be located in the /tmp directory of both the local and remote machines).

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
v2.1.0 >=8.1 >=9 MIT
v2.0.5 >=8.1 >=9 MIT
v2.0.4 >=8.1 >=9 MIT
v2.0.3 >=8.1 >=9 MIT
v2.0.2 >=8.1 >=9 MIT