- How do I install and use ifsnop/mysqldump-php in a Laravel app?
- Install it with composer require ifsnop/mysqldump-php. It has no required dependencies beyond the PDO MySQL extension and registers no Laravel service provider, so there is nothing to auto-discover. The idiomatic Laravel pattern is a thin wrapper you own, such as an App\Services\DatabaseDumper class that builds a Mysqldump instance with your DSN and explicitly overridden dumpSettings, invoked from an Artisan command scheduled with Schedule::command. Keep table include and exclude lists, masking rules and the destination disk in config/backup.php.
- Does mysqldump-php work with Laravel 10 or 11 on PHP 8.2 and 8.3?
- The library is framework-agnostic pure PHP, so nothing in it blocks modern Laravel versions, but the README test matrix is stale and lists PHP 5.3 through 7.3 plus HHVM. Treat PHP 8.2, PHP 8.3 and MySQL 8 as unverified in your environment and run your own smoke tests for deprecations such as dynamic properties and PDO constant changes. Validate a full dump and restore cycle on your exact Laravel, PHP and MySQL versions before depending on it.
- Is the GPL-3.0 license a problem for a commercial Laravel product?
- Potentially yes. GPL-3.0 is a copyleft license, so bundling the library inside a distributed or on-prem Laravel product is exposure that most legal teams reject outright. Internal and SaaS use usually does not trigger distribution obligations, but many organizations still ban GPL packages in application dependencies regardless. The safe pattern is require-dev only, using it for seed and fixture dumps, and never shipping it in a distributed artifact.
- Can I use mysqldump-php when exec() is disabled or the mysqldump binary is missing?
- That is the main reason to pick it. Because it connects over PDO and writes SQL from inside the PHP process, it works in distroless or read-only containers, Cloud Run and Lambda style PaaS runtimes, Kubernetes pods without a MySQL client, and hardened shared hosting where exec is disabled. It produces logical SQL-text dumps only, so it is not a substitute for physical backups or point-in-time recovery.
- How do I stream a mysqldump-php backup to S3 or Google Cloud Storage without local disk?
- Enable the compression option together with the bundled GZIPSTREAM stream wrapper so the dump is written compressed straight to the destination. This avoids touching the ephemeral filesystem of container platforms, which matters when pods or instances can be recycled mid-dump. Confirm the gzip extension and stream wrappers you need are enabled in the runtime and benchmark throughput on a realistic database size first.
- How do I mask or anonymize PII during a mysqldump-php dump?
- Register a callback with setTransformTableRowHook so each row is rewritten before it is emitted as SQL, which lets you replace emails, names or tokens with deterministic fake values for GDPR-safe staging and seed data. Pair it with setTableWheres and setTableLimits to scope the export further. Keep the callback fast and side-effect free, because it runs once per row and can dominate dump time on large tables.
- How do I dump only certain tables or a limited number of rows with mysqldump-php?
- Pass includeTables or excludeTables in dumpSettings, then use setTableWheres for row filters and setTableLimits to cap rows per table. This is useful for scoped fixture or staging dumps rather than full production backups. Remember the limit applies per table, so it does not bound the total dump size when many tables are included.
- What PDO settings should I override when running mysqldump-php in Laravel?
- The shipped defaults include PDO::ATTR_PERSISTENT set to true and MYSQL_ATTR_USE_BUFFERED_QUERY set to false, which are risky inside long-lived workers. Persistent connections and unbuffered queries under Horizon or Octane can pin connections, leak stale session state and trigger commands out of sync errors. Always pass explicit pdoSettings in your wrapper instead of relying on defaults, and add connect and read timeouts so a stalled dump cannot hang a queue worker.
- Can mysqldump-php restore a dump when the mysql client is not installed?
- Yes. It can restore a dump from a file when no mysql executable is available, which keeps the entire backup and restore loop inside PHP and works in the same restricted runtimes that make the dump side attractive. Restores are slower than piping into the native client, so use this for small and medium databases and rehearse the restore drill against your actual RTO target.
- Is mysqldump-php maintained, and what should I use for large production databases?
- It is effectively a single-maintainer project, with a self-described hacky test suite and CI badges referencing Travis and old PHP versions, so treat release cadence and PHP 8 support as things to verify on Packagist rather than assume. It fits small to medium logical SQL dumps, especially where the mysql binary is unavailable or forbidden. For very large databases, encryption at rest with your own KMS keys, scheduling, retention or point-in-time recovery, use managed PITR, xtrabackup or a dedicated backup platform instead.