gilles-g / dump-loader-bundle
Symfony bundle loading a SQL dump into the application database, with a live web UI.
Package info
github.com/gilles-g/dump-loader-bundle
Type:symfony-bundle
pkg:composer/gilles-g/dump-loader-bundle
Requires
- php: >=8.4
- league/flysystem: ^3
- league/flysystem-local: ^3
- psr/clock: ^1.0
- symfony/clock: ^6.4|^7.4|^8.0
- symfony/config: ^6.4|^7.4|^8.0
- symfony/console: ^6.4|^7.4|^8.0
- symfony/dependency-injection: ^6.4|^7.4|^8.0
- symfony/framework-bundle: ^6.4|^7.4|^8.0
- symfony/http-kernel: ^6.4|^7.4|^8.0
- symfony/lock: ^6.4|^7.4|^8.0
- symfony/process: ^6.4|^7.4|^8.0
- symfony/security-csrf: ^6.4|^7.4|^8.0
- symfony/string: ^6.4|^7.4|^8.0
- symfony/translation: ^6.4|^7.4|^8.0
- symfony/twig-bundle: ^6.4|^7.4|^8.0
- symfony/uid: ^6.4|^7.4|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- league/flysystem-memory: ^3
- phpstan/phpstan: ^2.1
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^13.4
- rector/rector: ^2.1
- symfony/browser-kit: ^6.4|^7.4|^8.0
- symfony/css-selector: ^6.4|^7.4|^8.0
- symfony/phpunit-bridge: ^6.4|^7.4|^8.0
- symfony/tui: ^8.1
- symfony/yaml: ^6.4|^7.4|^8.0
Suggests
- gilles-g/db-anonymizer: To anonymize the database as a step of a dump load.
- league/flysystem-aws-s3-v3: To read dumps from an S3 bucket.
- league/flysystem-sftp-v3: To read dumps from an SFTP server.
- symfony/security-bundle: To identify the requester of a load job.
- symfony/tui: Rich terminal UI for dump-loader:load (PHP 8.4.1+, Symfony 8.1+).
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-04 10:10:39 UTC
README
Load a SQL dump into your Symfony app's database from a web UI, and watch it run live.
Warning
Drops every table of the target database. Dev and staging only, behind an authenticated route.
- Pick a dump (
.sql,.sql.gz), tick options, follow steps, progress and log in real time. - Abort at any time. Every job is kept in history.
- Streaming restore: memory stays flat, whatever the dump size.
- The monitor runs on its own kernel and keeps answering while the app cannot boot.
- Same flow from the terminal, scriptable in CI.
- Add your own steps: password reset, anonymization…
Requirements
- PHP 8.4+ with
zlibandpdo_mysql, Symfony 6.4, 7.4 or 8.1+ - MySQL or MariaDB, and the
mysqlclient in the PHP image clear_env = noin the php-fpm poolvar/dump-loaderwritable,bin/consoleexecutable by php-fpm- Linux or macOS
Install
composer require gilles-g/dump-loader-bundle
Register DumpLoader\DumpLoaderBundle::class => ['all' => true] in config/bundles.php.
config/packages/dump_loader.yaml
dump_loader: source: directory: '%kernel.project_dir%/var/dumps' target_database: dsn: '%env(DATABASE_URL)%'
config/routes/dump_loader.yaml
dump_loader: resource: '@DumpLoaderBundle/Resources/config/routes.php' prefix: /dump-loader
config/packages/security.yaml
security: access_control: - { path: ^/dump-loader, roles: ROLE_ADMIN }
public/index.php: mount the monitor before the app kernel, so it survives the DROP TABLE.
return function (array $context) { $uri = $_SERVER['REQUEST_URI'] ?? ''; if (str_starts_with($uri, '/dump-loader/monitor') && \in_array($context['APP_ENV'], ['dev', 'staging'], true)) { return new DumpLoader\Monitor\MonitorKernel( $context['APP_ENV'], (bool) $context['APP_DEBUG'], dirname(__DIR__), '/dump-loader/monitor', ); } return new App\Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); };
Keep the APP_ENV guard: without it, the monitor answers in production.
Then check the host, drop a dump in var/dumps and open /dump-loader:
bin/console dump-loader:check
Command line
bin/console dump-loader:load bin/console dump-loader:load dumps/prod.sql.gz --option=run_migrations --force -n
Interactive by default, fully scripted with -n. Exits 0 only if the load completed.
Run a command after the load
dump_loader: after_load: reset_admin_password: label: 'Reset the admin password' command: ['dbal:run-sql', 'UPDATE admin_user SET password = "%env(ADMIN_PASSWORD)%" WHERE id = 1']
Shows up as a checkbox in the UI. Need PHP? Implement DumpLoader\Step\OptionalStep, see
custom steps.
Documentation
Contributing
Run make quality before opening a pull request. make help lists every target.
License
MIT, see LICENSE.