Download the PHP package webfactory/slimdump without Composer

On this page you can find all versions of the php package webfactory/slimdump. 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 slimdump

webfactory Logo slimdump

Build Status Coverage Status

slimdump is a little tool to help you create configurable dumps of large MySQL-databases. It works off one or several configuration files. For every table you specify, it can dump only the schema (CREATE TABLE ... statement), full table data, data without blobs and more.

Why?

We created slimdump because we often need to dump parts of MySQL databases in a convenient and reproducible way. Also, when you need to analyze problems with data from your production databases, you might want to pull only relevant parts of data and hide personal data (user names, for example).

mysqldump is a great tool, probably much more proven when it comes to edge cases and with a lot of switches. But there is no easy way to create a simple configuration file that describes a particular type of dump (e.g. a subset of your tables) and share it with your co-workers. Let alone dumping tables and omitting BLOB type columns.

Installation

When PHP is your everyday programming language, you probably have Composer installed. You can then easily install slimdump as a global package. Just run composer global require webfactory/slimdump. In order to use it like any other Unix command, make sure $COMPOSER_HOME/vendor/bin is in your $PATH.

Of course, you can also add slimdump as a local (per-project) Composer dependency.

We're also working on providing a .phar package of slimdump for those not using PHP regularly. With that solution, all you need is to have the PHP interpreter installed and to download a single archive file to use slimdump. You can help us and open a pull request for that :-)!

Usage

slimdump needs the DSN for the database to dump and one or more config files:

slimdump {DSN} {config-file} [...more config files...]

slimdump writes to STDOUT. If you want your dump written to a file, just redirect the output:

slimdump {DSN} {config-file} > dump.sql

If you want to use an environment variable for the DSN, replace the first parameter with -:

MYSQL_DSN={DSN} slimdump - {config file(s)}

The DSN has to be in the following format:

mysql://[user[:password]@]host[:port]/dbname[?charset=utf8mb4]

For further explanations have a look at the Doctrine documentation.

Optional parameters and command line switches

no-progress

This turns off printing some progress information on stderr. Useful in scripting contexts.

Example: slimdump --no-progress {DSN} {config-file}

buffer-size

You can also specify the buffer size, which can be useful on shared environments where your max_allowed_packet is low. Do this by using the optional cli-option buffer-size. Add a suffix (KB, MB or GB) to the value for better readability.

Example: slimdump --buffer-size=16MB {DSN} {config-file}

single-line-insert-statements

If you have tables with a large number of rows to dump and you are not planning to keep your dumps under version control, you might consider writing each INSERT INTO-statement to a single line instead of one line per row. You can do this by using the cli-parameter single-line-insert-statements. This can speed up the import significantly.

Example: slimdump --single-line-insert-statements {DSN} {config-file}

output-csv

This option turns on the CSV (comma separated values) output mode. It must be given the path to a directory where .csv files will be created. The files are named according to tables, e. g. my_table.csv.

CSV files contain only data. They are not created for views, triggers, or tables dumped with the schema dump mode. Also, no files will be created for empty tables.

Since this output format needs to write to different files for different tables, redirecting stdout output (as can be done for the default MySQL SQL mode) is not possible.

Experimental Feature CSV support is a new, experimental feature. The output formatting may change at any time.

Configuration

Configuration is stored in XML format somewhere in your filesystem. As a benefit, you could add the configuration to your repository to share a quickstart to your database dump with your coworkers.

Example:

Conditions

You may want to select only some rows. In that case you can define a condition on a table.

In this example, only users with a username starting with 'foo' are exported: A simple way to export roughly a percentage of the users is this:

This will export only the users with an id divisible by ten without a remainder, e.g. about 1/10th of the user rows (given the ids are evenly distributed).

If you want to keep referential integrity, you might have to configure a more complex condition like this:

In this case, we export only users that are referenced in other tables, e.g. that are authors of blog posts or comments.

Dump modes

The following modes are supported for the dump attribute:

Wildcards

Of course, you can use wildcards for table names (* for multiple characters, ? for a single character).

Example:

This is a valid configuration. If more than one instruction matches a specific table name, the most specific one will be used. E.g. if you have definitions for blog_* and blog_author, the latter will be used for your author table, independent of their sequence order in the config.

Replacements

You probably don't want to use any personal data from your database. Therefore, slimdump allows you to replace data on column level - a great instrument not only for General Data Protection Regulation (GDPR) compliance.

The simplest replacement is a static one:

This replaces the password values of all users with "test" (in clear text - but for sure you have some sort of hashing in place, do you?).

To achieve realistically sounding dummy data, slimdump also allows basic Faker formatters. You can use every Faker formatter which needs no arguments and modifiers such as unique (just seperate the modifier with an object operator (->), as you would do in PHP). This is especially useful if your table has a unique constraint on a column containing personal information, like the email address.

Other databases

Currently, only MySQL is supported. Feel free to port it to the database of your needs.

Development

Building the Phar

Tests

You can execute the phpunit-tests by calling vendor/bin/phpunit.

Credits, Copyright and License

This tool was written by webfactory GmbH, Bonn, Germany. We're a software development agency with a focus on PHP (mostly Symfony). We're big fans of automation, DevOps, CI and CD, and of open source in general.

If you're a developer looking for new challenges, we'd like to hear from you! Otherwise, if this tool is useful for you, add a ⭐️.

Copyright 2014-2022 webfactory GmbH, Bonn. Code released under the MIT license.


All versions of slimdump with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.1, <8.4
ext-simplexml Version *
ext-libxml Version *
ext-pdo Version *
doctrine/dbal Version ^2.13|^3.0
doctrine/event-manager Version ^1.0|^2.0
fakerphp/faker Version ^1.14
symfony/console Version ^4.0|^5.0|^6.0|^7.0
symfony/service-contracts Version ^2.1.2|^3.0
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 webfactory/slimdump contains the following files

Loading the files please wait ....