Download the PHP package smwks/laravel-db-snapshots without Composer

On this page you can find all versions of the php package smwks/laravel-db-snapshots. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-db-snapshots

Laravel DB Snapshots

Database snapshots for Laravel using native CLI tools (mysqldump, pg_dump, gzip, etc.). Create compressed snapshots of your production database, store them on any Laravel filesystem disk, and load them into your local environment with a single command.

Supports MySQL/MariaDB and PostgreSQL with automatic driver detection from your Laravel database config.

Installation

Publish the config file:

This creates config/db-snapshots.php.

How It Works

The package revolves around plans -- named snapshot configurations. A plan defines which database connection to use, how to name the files, which tables to include or exclude, and where to store the results.

The typical workflow:

  1. Production: db-snapshots:create runs mysqldump (or pg_dump), compresses the output with gzip, and uploads it to your archive disk (e.g. S3).
  2. Local: db-snapshots:load downloads the latest snapshot, drops your local tables, and pipes the dump through zcat into mysql (or psql).

Configuration

Filesystem

Snapshots are stored on a Laravel filesystem disk. The archive disk is where snapshots are permanently stored (typically a cloud disk like S3). The local disk is used for temporary caching during downloads.

Plans

Each plan defines a snapshot configuration:

File Templates

The file_template controls snapshot file naming. It must contain a {date:FORMAT} placeholder using PHP date format characters:

Template Example Filename
db-snapshot-daily-{date:Ymd} db-snapshot-daily-20250209.sql.gz
db-snapshot-hourly-{date:YmdH} db-snapshot-hourly-2025020914.sql.gz
db-snapshot-{date:Ymd-His} db-snapshot-20250209-143022.sql.gz

Table Selection

You have three ways to control which tables are included:

tables and ignore_tables cannot both be set on the same plan.

schema_only_tables dumps the table structure without data -- useful for large tables like failed_jobs where you need the schema but not the rows. When using tables, any schema_only_tables must also appear in the tables list.

Dump Options

The dump_options string is passed directly to the dump utility. Common values:

Environment Locks

Environment locks prevent accidental operations. With the default config, snapshots can only be created in production and only loaded in local. Set either to null to allow the operation in any environment.

Plan Groups

Plan groups let you batch multiple plans together. This is useful when your application uses multiple databases:

Plan groups work with db-snapshots:create and db-snapshots:load -- pass the group name instead of a plan name.

Caching

When loading snapshots, the file is downloaded to the local disk, loaded into the database, then deleted. You can keep local copies to speed up repeated loads:

Or use the --cached / --recached flags on the load command (see below).

Utilities

The package needs CLI tools available on the system. Configure custom paths if they're not in your $PATH:

Post-Load SQL Commands

SQL commands can be configured at three levels, and they run in this order:

  1. Global (post_load_sqls at the config root) -- runs after every snapshot load
  2. Plan-level (post_load_sqls inside a plan) -- runs after that specific plan loads
  3. Plan group-level (post_load_sqls inside a plan group) -- runs after all plans in the group have loaded

Commands

db-snapshots:create

Create a snapshot.

db-snapshots:load

Download and load a snapshot into your local database. By default this drops all tables before loading.

Use -v for verbose output to see the exact commands being run.

db-snapshots:list

List available snapshots, cached files, and plan groups.

db-snapshots:delete

Delete a snapshot from the archive.

db-snapshots:clear-cache

Remove locally cached snapshot files.

Database Driver Support

The database driver is auto-detected from your Laravel connection config (database.connections.{name}.driver). No manual configuration is needed.

Driver Dump Tool Load Tool Credentials
MySQL / MariaDB mysqldump mysql Temporary .my.cnf file with --defaults-extra-file
PostgreSQL pg_dump psql Temporary pgpass file via PGPASSFILE

Compression (gzip / zcat) is handled the same way for all drivers.

Requirements

Testing

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-db-snapshots with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package smwks/laravel-db-snapshots contains the following files

Loading the files please wait ...