Brings db:export
and db:import
artisan commands to Laravel, to easily copy database to another environment.
Ever worked with Wordpress and used the WP-Cli ? How handful are wp db:export
and wp db:import
commands... 😻
This package brings the same functionality to Laravel. You can...
- ... export database to a SQL file :
❯ php artisan db:export /path/to/file.sql
Exporting database to /path/to/file.sql
Database exported successfully.
- ... import database from an SQL file :
❯ php artisan db:import /path/to/file.sql
Importing database from /path/to/file.sql
Database imported successfully.
This package uses spatie/db-dumper in the background to generate db exports.
This package requires php >= 8.1
and laravel >= 8.0
.
You can install the package via composer:
composer require hydrat-agency/laravel-db-dumper
Database | Export | Import |
---|---|---|
MySQL | ✅ | ✅ |
MariaDB | ✅ | |
PostgreSQL | ||
SQLite | ✅ | |
SQL Server |
- Exporting to a file :
php artisan db:export /path/to/file.sql # full path
php artisan db:export ../dump.sql # relative path
ℹ If you don't provide a filename in your path, a name will be automatically generated :
❯ php artisan db:export
Exporting database to /path/to/project/dbname_2022-10-05_09-59-48.sql
Database exported successfully.
- Importing from a file :
php artisan db:import /path/to/file.sql # full path
php artisan db:import ../dump.sql # relative path
# Using instance
$dumper = new Hydrat\LaravelDbDumper\LaravelDbDumper();
$dumper->dumpTo('path/to/file.sql', 'dbname');
$dumper->importFrom('path/to/file.sql');
# Using facade
use Hydrat\LaravelDbDumper\Facades\LaravelDbDumper;
LaravelDbDumper::dumpTo('path/to/file.sql', 'dbname');
LaravelDbDumper::importFrom('path/to/file.sql');
composer test
Please see CHANGELOG for more information on what has changed recently.
Feel free to contribute !
If you find any security vulnerabilities, please don't report it publicly.
Instead, contact me by private message or at thomas@hydrat.agency.
The MIT License (MIT). Please see License File for more information.