PHPackages                             swiftotter/driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. swiftotter/driver

ActiveLibrary[Database &amp; ORM](/categories/database)

swiftotter/driver
=================

A database task-runner that helps you to turn production database into a staging/development database sandbox

v4.0.0(3y ago)6111.1k↓33.3%9[5 issues](https://github.com/SwiftOtter/Driver/issues)[1 PRs](https://github.com/SwiftOtter/Driver/pulls)2Apache-2.0PHPPHP ^7.4|^8.0

Since Dec 7Pushed 3y ago15 watchersCompare

[ Source](https://github.com/SwiftOtter/Driver)[ Packagist](https://packagist.org/packages/swiftotter/driver)[ RSS](/packages/swiftotter-driver/feed)WikiDiscussions 4.1-develop Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (58)Used By (2)

Driver
======

[](#driver)

Driver is a database task-runner that helps you to turn production database into a staging/development database sandbox.

Description
-----------

[](#description)

Driver is the easy way to turn a production database into a staging or development-friendly database. It is built with the aim of complete flexibility. Additionally, with the built-in capability of working with RDS, Driver can run transformations on database host that is completely separate from your production environment.

Driver resides on your production machine, with your website's codebase (via Composer). You set up a CRON job to run Driver.

- Driver connects to your production database ONCE via `mysqldump`.
- Driver dumps that to a file on your system.
- Driver creates an RDS instance and pushes the database dump up to RDS (via https).
- Driver runs whatever actions you would like (configured globally or per environment).
- Driver dumps the transformed data, zips it and pushes it up to S3.
- You can then download transformed dump from S3 to your staging/development machine, also using Driver.

For a 3-5GB database, this process could take an hour or two. This depends on how many environments you are creating and what type of RDS instance you are using. This causes no downtime to the frontend thanks to the `--single-transaction` flag on `mysqldump`. Yes, it does take a while to run, but there is little-to-no impact on the frontend.

Before We Start
---------------

[](#before-we-start)

At Swift Otter we mainly work with Magento 2. We created separate repo for Magento 2 Driver transformations. It includes config for anonymization of all database tables of core Magento 2 system. If you are Magento 2 developer, we recommend you to install that repo, instead of this one (Driver would be installed anyway, as it is a dependency of that Magento 2 repo). If you're not a Magento 2 developer, we still recommend you to look at that repo to get a better idea on how things can be configured for your project.

Magento 2 Driver transformations repo can be found [here](https://github.com/swiftotter/Driver-Magento2).

Getting Started
---------------

[](#getting-started)

### Dependencies

[](#dependencies)

- PHP 7.4 or higher

### Prerequisites

[](#prerequisites)

You need to create an Amazon AWS account. We will be using RDS to perform the data manipulations. It is recommended to create a new IAM user with appropriate permissions to access EC2, RDS and S3 (exact permissions will be coming). This is explained in details [here](docs/aws-setup.md).

### Installation

[](#installation)

```
composer require swiftotter/driver
```

### Configuration

[](#configuration)

#### Overview of Config Structure

[](#overview-of-config-structure)

Driver configuration goes into a folder named `.driver`. The files that are recognized inside this folder are:

- `anonymize.yaml`
- `commands.yaml`
- `config.yaml`
- `connections.yaml`
- `engines.yaml`
- `environments.yaml`
- `pipelines.yaml`
- `reduce.yaml`
- `update_values.yaml`

The filenames of these files serve no purpose other than a namespace. The delineation of the configuration happens inside each file. For example, in `pipelines.yaml`, there is a `pipelines` node as the root element. In this way, the YAML itself is providing namespaces. This also has the benefit for you of being able to put all of your updates in one file (for example, `config.yaml`).

Driver looks in quite a few places for configuration files. As an example, let's say your application is stored in `/var/www/`. Your vendor directory is `/var/www/vendor/` and, of course, Driver's home is `/var/www/vendor/swiftotter/driver`. As such, Driver will look in the following locations for configuration files:

- `/var/www/.driver/`
- `/var/www/vendor/*/*/.driver/`

You can symlink any file you want here. Keep in mind that these files do contain sensitive information, and it is necessary to include a `.htaccess` into that folder: `Deny from all`

#### Connections Configuration

[](#connections-configuration)

You have to configure connections information for your project. In the folder that contains your `vendor` folder, create a folder called `.driver`. Next, copy the file `vendor/swiftotter/driver/.driver/connections.yaml.dist` to `.driver/connections.yaml`and fill it in with your source MySQL information, as well as destination EC2, RDS and S3 data.

Exemplary config can be found in `vendor/swiftotter/driver/.driver/connections.yaml.example`.

#### Environments Configuration

[](#environments-configuration)

Environments allow to make modifications to the database, per-site. You can configure different set of actions for every environment. For example, for local environment you may want to clear out all admin users as well as set unique URLs for the website and possibly other things.

**Note:** You can execute specific commands per environment. These changes do not revert for each environment, but rather they are applied according to their sort order. If one environment uses the data in the `admin_users` table, and another environment clears out all data in the `admin_users` table, you set the sort order for the first environment lower (ex. `100`) and the sort order for the second environment higher (ex. `200`).

To configure your environments copy the file `vendor/swiftotter/driver/.driver/environments.yaml.dist`to `.driver/environments.yaml` and fill it in with your environments data.

Exemplary config can be found in `vendor/swiftotter/driver/.driver/environments.yaml.example`.

#### Anonymization Configuration

[](#anonymization-configuration)

Tables can be anonymized by creating `anonymize.yaml` file in `.driver/`. The following type of anonymization entities are available in order to provide realistic data and types:

- `email`
- `company`
- `firstname`
- `lastname`
- `phone`
- `postcode`
- `street`
- `city`
- `ip`
- `general`
- `empty`

**Example File**

```
anonymize:
  tables:
    quote:
      customer_email:
        type: email
      remote_ip:
        type: ip

```

#### Post-Anonymization Values Updates Configuration

[](#post-anonymization-values-updates-configuration)

Sometimes in your database you can store in a single field some value that was originally built by concatenating fields from different tables, eg. `full_name` or `shipping_address`. Driver allows to run some specific values updates after anonymization of simple fields is finished. Thanks to this feature you can anonymize such complex fields too.

To create post-anonymization values updates, create `update_values.yaml` file in `.driver/`.

**Example File**

```
update-values:
  tables:
    customer_grid_flat:
      joins:
        - table: customer_entity
          alias: c
          on: c.entity_id = customer_grid_flat.entity_id
        - table: customer_address_entity
          alias: ba
          on: ba.entity_id = c.default_billing
        - table: customer_address_entity
          alias: sa
          on: sa.entity_id = c.default_shipping
      values:
        - field: name
          value: CONCAT_WS(' ', c.firstname, c.lastname)
        - field: shipping_full
          value: CONCAT(sa.street, ', ', sa.city, ', ', IFNULL(sa.region, '-'), ' ', sa.postcode, ', ', sa.country_id)
        - field: billing_full
          value: CONCAT(ba.street, ', ', ba.city, ', ', IFNULL(ba.region, '-'), ' ', ba.postcode, ', ', ba.country_id)

```

Usage
-----

[](#usage)

### Building Database Sandboxes For All Environments

[](#building-database-sandboxes-for-all-environments)

Be prepared for it to take some time (on the order of hours).

```
./vendor/bin/driver run

```

### Building Database Sandbox For Single Environment

[](#building-database-sandbox-for-single-environment)

```
./vendor/bin/driver run build --environment=envname
```

where `envname` is one of the environments defined in `environments.yaml` config file.

### Tagging Database Sandbox

[](#tagging-database-sandbox)

Sandboxes built with a tag will include the tag in the file name.

```
./vendor/bin/driver run build --tag=tagname
```

where `tagname` is an issue number (or whatever is desired).

### Download and Import Sandbox Database from S3 to staging/local environment

[](#download-and-import-sandbox-database-from-s3-to-staginglocal-environment)

The below command run the export/import pipeline which download the database into your project `var/` directory, create new database in MySQL, and import the downloaded database in it for your environment.

```
./vendor/bin/driver run import-s3 --environment=envname --tag=tagname

```

`tag` is optional.

Contribution
------------

[](#contribution)

We welcome you to contribute in Driver development. You can find some handy information for developers [here](docs/development.md).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Recently: every ~23 days

Total

40

Last Release

1186d ago

Major Versions

0.5.2 → 1.0.02017-05-03

v1.2.2 → v2.02020-02-08

v2.2 → v3.0.02021-02-20

v2.3 → v3.0.12021-03-18

v3.5.0 → v4.0.0-alpha2022-07-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/0caf0b4442f87bd5fa93aec6a384421bb76a9f4b2e316e3e30a642783512a482?d=identicon)[JosephMaxwell](/maintainers/JosephMaxwell)

---

Top Contributors

[![JosephMaxwell](https://avatars.githubusercontent.com/u/1151186?v=4)](https://github.com/JosephMaxwell "JosephMaxwell (67 commits)")[![michalbiarda](https://avatars.githubusercontent.com/u/1135380?v=4)](https://github.com/michalbiarda "michalbiarda (40 commits)")[![JesseMaxwell](https://avatars.githubusercontent.com/u/30010447?v=4)](https://github.com/JesseMaxwell "JesseMaxwell (13 commits)")[![prince-swiftotter](https://avatars.githubusercontent.com/u/72470372?v=4)](https://github.com/prince-swiftotter "prince-swiftotter (6 commits)")[![danielozano](https://avatars.githubusercontent.com/u/7377826?v=4)](https://github.com/danielozano "danielozano (5 commits)")[![bassplayer7](https://avatars.githubusercontent.com/u/1171147?v=4)](https://github.com/bassplayer7 "bassplayer7 (2 commits)")[![AntonioAPG](https://avatars.githubusercontent.com/u/29123547?v=4)](https://github.com/AntonioAPG "AntonioAPG (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/swiftotter-driver/health.svg)

```
[![Health](https://phpackages.com/badges/swiftotter-driver/health.svg)](https://phpackages.com/packages/swiftotter-driver)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
