The Laravel package that provides the Artisan command to execute mysqldump
.
Laravel MySQL Dumper has the following features:
- Dump all the database from the MySQL database
- Dump only the data from the MySQL database
- Dump only the schema from the MySQL database
- Dump from the MySQL database with your dump setting, such as
mysqldump
options
Laravel MySQL Dumper has the following requirements:
- PHP >= 7.3
- Laravel >= 6.0
Execute the Composer require
command:
composer require ngmy/laravel-mysql-dumper
This will update your composer.json
file and install this package into the vendor
directory.
If you don't use package discovery, add the service provider to the providers
array in the config/app.php
file:
Ngmy\LaravelMysqlDumper\MysqlDumperServiceProvider::class,
Execute the Artisan vendor:publish
command:
php artisan vendor:publish
This will publish the configuration file to the config/ngmy-mysql-dumper.php
file.
You can also use the tag to execute the command:
php artisan vendor:publish --tag=ngmy-mysql-dumper
You can also use the service provider to execute the command:
php artisan vendor:publish --provider="Ngmy\LaravelMysqlDumper\MysqlDumperServiceProvider"
php artisan mysql-dumper:dump
php artisan mysql-dumper:dump --setting=schema
php artisan mysql-dumper:dump --setting=data
Add the dump setting to the settings
array in the config/ngmy-mysql-dumper.php
file.
Then, use the dump setting to execute the command:
php artisan mysql-dumper:dump --setting=your_setting
Use the dump setting with the importalbe_with_laravel
option true
to execute the command:
php artisan mysql-dumper:dump
Then, use the unprepared
method to import the dump file, such as in your migration.
DB::unprepared(file_get_contents($dumpFile));