Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Mysqldump Php

Mysqldump Php Laravel Package

ifsnop/mysqldump-php

Pure-PHP mysqldump alternative with sane defaults and no external dependencies. Dumps schema, data, views, triggers, routines and events; supports blobs as hex, view dependency resolution, extended/complete inserts, insert-ignore, compression/streaming, hooks, and restore.

View on GitHub
Deep Wiki
Context7

PHP version of mysqldump cli that comes with MySQL

Frequently asked questions about Mysqldump Php
How do I integrate this package into a Laravel project for automated database backups?
Start by requiring the package via Composer (`composer require ifsnop/mysqldump-php:^2.11`), then create a custom Artisan command or service class to wrap the dumper. Use Laravel’s filesystem drivers (local/S3) to store backups, and schedule the command via `schedule:run` in your `app/Console/Kernel.php`. For async backups, dispatch the command to a queue.
Does this package support incremental backups or only full database dumps?
This package primarily supports full database dumps, but you can use the `--tables` or `--where` options to target specific tables or rows. For true incremental backups, consider combining this with Laravel’s `Schema::get()` or a custom solution that tracks changes via triggers or timestamps. There’s no built-in binary logging support like `mysqldump --master-data`.
Can I use this for Laravel SaaS multi-tenant backups (e.g., per-tenant SQL exports)?
Yes, you can filter backups by tenant using the `--where` clause (e.g., `--where='tenant_id = 1'`) or pre-process data with hooks. For large-scale SaaS, pair this with Laravel’s queue system to avoid timeouts. Store tenant-specific backups in separate files or folders, and use Laravel’s filesystem to manage paths dynamically.
What Laravel versions and PHP requirements does this package support?
The package works with Laravel 5.7+ and requires PHP 7.2+. Tested on PHP 7.3+ for stability, but older versions (5.3–7.3) are supported in legacy branches. Always pin to `^2.11` in `composer.json` to avoid breaking changes. Check your Laravel version’s PHP requirements first (e.g., Laravel 9 needs PHP 8.0+).
How do I restore a backup created with this package in Laravel?
Use the `MySqlDumper::restoreFromFile()` method to restore from a `.sql` or `.sql.gz` file. For Laravel integration, create a custom Artisan command (e.g., `php artisan db:restore`) that reads from storage (local/S3) and pipes the file to `PDO::exec()`. For production, test restores in staging first, and log failures to Laravel’s log channel or Sentry.
Will this work in CI/CD pipelines (e.g., GitHub Actions) for pre-deploy backups?
Absolutely. Replace `mysqldump` CLI calls with PHP code in your pipeline (e.g., `php artisan db:backup --storage=s3`). Use environment variables for credentials (via Laravel’s `.env`), and store backups in S3 or another Laravel-supported filesystem. For GitHub Actions, add a step like `run: php artisan db:backup --compress` before deployments.
How do I handle large databases (e.g., 10GB+) without memory exhaustion?
Use chunking with `--chunk-size=1000` and `--single-transaction` to avoid locks. For streaming, enable compression (`--compress`) and write directly to a file or S3 stream. In Laravel, dispatch the backup to a queue (e.g., `database` queue) to avoid HTTP timeouts. Monitor memory usage with `memory_get_usage()` and adjust chunk sizes if needed.
Can I customize the backup output (e.g., exclude tables, modify data with hooks)?
Yes, use the `--ignore-tables` option to exclude tables or `--where` to filter rows. For data transformation, leverage hooks via `MySqlDumper::addHook()` to modify queries or output. For example, you could anonymize PII before dumping. Hooks are chainable and run during the dump process.
What are the alternatives to this package, and when should I choose them?
Alternatives include `spatie/laravel-backup` (Laravel-specific, supports more storage backends) and `percona/percona-toolkit` (CLI-focused). Choose this package if you need pure PHP with no external dependencies, fine-grained control over dump settings, or compatibility with environments without `mysqldump`. Use `spatie/laravel-backup` if you prefer a Laravel-centric solution with built-in monitoring.
How do I secure credentials when using this package in Laravel?
Never hardcode credentials. Use Laravel’s `.env` file for database config (e.g., `DB_HOST`, `DB_PASSWORD`), and restrict file permissions. For production, integrate with a secrets manager like HashiCorp Vault or AWS Secrets Manager. Avoid logging credentials, and use Laravel’s `config('database')` to dynamically fetch connection details in your backup service.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/privacy-filter-classifier
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi