hydrat-agency / laravel-db-dumper
Brings db:export/db:import command to laravel for easier environment propagation
Requires
- php: >=8.1
- illuminate/contracts: ^9.0|^10.0
- spatie/db-dumper: ^3.3
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
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.
Installation
This package requires php >= 8.1
and laravel >= 8.0
.
You can install the package via composer:
composer require hydrat-agency/laravel-db-dumper
Usage
Supported databases
Using Db Dumper from artisan CLI
- 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 Db Dumper from your code
# 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');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Feel free to contribute !
Security Vulnerabilities
If you find any security vulnerabilities, please don't report it publicly.
Instead, contact me by private message or at thomas@hydrat.agency.
Credits
License
The MIT License (MIT). Please see License File for more information.