bestuniverse / laravel-toolkit
MySQL backup and import commands for Laravel applications.
Requires
- php: ^8.3
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.5|^12.0
README
Utilities for Laravel applications that need to create and restore MySQL database backups.
Requirements
- PHP 8.3 or later
- Laravel 12 or 13
- The
mysqldumpandmysqlexecutables available on the systemPATH
Installation
Install the package with Composer:
composer require bestuniverse/laravel-toolkit
Laravel discovers the service provider automatically. Publish the configuration when you need to change the backup disk or directory:
php artisan vendor:publish --tag=laravel-toolkit-config
This creates config/laravel-toolkit.php:
return [ 'disk' => 'local', 'directory' => 'mysql-backup', ];
The configured disk must be defined in your application's config/filesystems.php.
Commands
Create a backup
Create a MySQL backup using the application's mysql database connection:
php artisan db:backup
Backup files are written to the configured disk and directory, for example storage/app/mysql-backup/live_2026_09_01_120000_full.sql when using the local disk.
Import a backup
Import a specific SQL file from the configured backup directory:
php artisan db:import live_2026_09_01_120000_full.sql
When no filename is supplied, the command interactively asks which .sql file to import:
php artisan db:import
Database connection values are taken from the application's mysql connection. You can override them for an individual import:
php artisan db:import backup.sql --user=root --pass=secret --db=example
Imports are blocked in the production environment unless you explicitly confirm them:
php artisan db:import backup.sql --force
Warning: Importing a SQL backup can overwrite or delete existing database data. Verify the selected file and target database before running the command.
Testing
composer test
License
Laravel Toolkit is open-sourced software licensed under the MIT license.