spatie/db-dumper
A PHP package for dumping MySQL, MariaDB, PostgreSQL, SQLite, and MongoDB databases with a fluent API. It wraps native tools like mysqldump and pg_dump, letting you write a dump straight to a file in just a few lines of code.
mysqldump, mariadb-dump, pg_dump, sqlite3, or mongodump and gives you a fluent, testable PHP API. That means the "do we write our own dump command builder?" question is settled — the real product decision shifts to what sits around it: scheduling, storage, retention, encryption, PII redaction, restore verification, and audit trail. Budget engineering weeks there, not days here.includeTables() / excludeTables() let you scope a per-tenant export to exactly that tenant's tables, and dumpToFile() gives you an artifact to zip, sign, and hand out. This is the lowest-effort path to shipping a defensible "download my data" feature.excludeTablesData() and excludeTables() options let you strip logs, sessions, and cache tables so support bundles stay small and lower-risk.skipAutoIncrement() exists precisely to avoid primary-key collisions when importing a dump into another environment; excludeTablesData(['logs','sessions']) keeps dumps lean. This directly supports a decision like "refresh staging weekly from a curated prod subset" instead of hand-maintained fixtures.useAppendMode() plus doNotCreateTables() / doNotDumpData() lets you compose a schema-only dump and a targeted data-only dump into one file — useful for demo seeding, migration snapshots, or shipping "migrations + reference data, no customer data."useCompressor(new GzipCompressor()) keeps storage cost down.Adopt when:
BackupService interface.setDatabaseUrl() handles the parsing, which matters if your platform standardizes on DATABASE_URL.getDumpCommand() writes credentials to a temp file; confirm how that file is created, permissioned, and cleaned up before it goes near production.Look elsewhere when:
Due-diligence flags to raise before committing: the package's metadata shows zero declared dependents despite being a well-known utility, and its overall score (~29.7) with a middling opportunity score (~49) reads as "solved, low-differentiation plumbing." Treat it as a commodity dependency, not a strategic bet. Also confirm the PHP-version support matrix and pin a minor version — it's Spatie-maintained with regular releases, which is healthy, but you want a deliberate upgrade cadence rather than floating ^2.
For executives (one paragraph): This is a small, free, MIT-licensed PHP library that turns "dump the database" into three lines of code across MySQL, MariaDB, PostgreSQL, SQLite, and MongoDB. It is mature and actively maintained, and it eliminates roughly a week of fiddly, error-prone work building and escaping native dump commands ourselves. Its strategic value is that it makes several features cheap — customer data exports, support snapshot attachments, staging refreshes, and pre-deploy safety snapshots — without requiring us to build a backup platform. Crucially, it is only the dump. Scheduling, storage, retention, encryption, access control, and — most importantly — tested restore procedures remain our responsibility and our real cost. Recommendation: adopt it as an internal commodity dependency behind a thin wrapper, and redirect the saved effort into the restore and retention story, which is where customers and auditors actually judge us.
For engineering (bullet summary):
Compressor interface for our own), append mode for two-step dumps, and AUTO_INCREMENT control for cross-environment imports.getDumpCommand(). Review file permissions and cleanup, and prefer dumpToFile() where it manages the lifecycle.DatabaseDumper interface of our own so replacing the package, or swapping to a managed snapshot API for specific environments, is a contained change.How can I help you explore Laravel packages today?