ngmy / laravel-mysql-dumper
The Laravel package that provides the Artisan command to execute mysqldump.
Fund package maintenance!
ngmy
flattr.com/@ngmy
Installs: 86 982
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 3
Requires
- php: ^7.3|^8.0
- ifsnop/mysqldump-php: ^2.9
- illuminate/support: ^6.0|^7.0|^8.0
Requires (Dev)
- nunomaduro/larastan: 0.6.11
- orchestra/testbench: 4.13.0|5.12.1|6.7.2
This package is auto-updated.
Last update: 2024-10-30 01:31:58 UTC
README
The Laravel package that provides the Artisan command to execute mysqldump
.
Features
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
Requirements
Laravel MySQL Dumper has the following requirements:
- PHP >= 7.3
- Laravel >= 6.0
Installation
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,
Publishing Configuration
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"
Usage
Dump All the Database
php artisan mysql-dumper:dump
Dump Only the Schema
php artisan mysql-dumper:dump --setting=schema
Dump Only the Data
php artisan mysql-dumper:dump --setting=data
Dump with Your Dump Setting
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
Dump to Import with Laravel
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));