PHPackages                             rrd108/data-mixer - 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. rrd108/data-mixer

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

rrd108/data-mixer
=================

A simple tool to create test data from existing database by mixing records

0.0.1(8y ago)010[3 issues](https://github.com/rrd108/data-mixer/issues)MITPHP

Since Dec 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rrd108/data-mixer)[ Packagist](https://packagist.org/packages/rrd108/data-mixer)[ RSS](/packages/rrd108-data-mixer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

data-mixer
==========

[](#data-mixer)

A simple PHP tool to create test data from existing database by mixing records.

Sometimes you want to test your application with the same amount of data what you have in your production enviroment. This script reads your exisiting data and mix its content.

Installation
============

[](#installation)

`composer --require-dev rrd108/data-mixer`

Usage
=====

[](#usage)

1. Create a backup of your production data and copy it to your development enviroment. **NEVER** use this tool in production, as you can accidently mix your data. **NO RESTORE, NO UNDO, NO CANCEL** method, what is mixed once, can not be reverted without a backup.
2. Create a new object in your code. DataMixer accepts the same arguments as PDO. `$dataMixer = new DataMixer('mysql:dbname=test;host=localhost', 'user', 'superSecret');`
3. Define your selected fields to be mixed in the `$fields` variable.
4. Get your mixed data and modify it if you want. `$mixed = $dataMixer->getMixed($table, $fields);`
5. Update your records in tha database. This will actually update your database, so be careful, **NO RESTORE, NO UNDO, NO CANCEL** method. `$dataMixer->updateRows($mixed);`

`$fields` array
===============

[](#fields-array)

The fields defined in `$fields` array will be mixed.

Simple mixing
-------------

[](#simple-mixing)

```
$fields = ['first_name', 'last_name'];
```

In this case in the `$table` database table all records' `first_name` and `last_name` values will be mixed randomly. All other table fields will be unchaned.

Let's say we have the following *starter* table.

idfirst\_namelast\_namepassport\_numbersex1JohnDoe123456789AAM2JaneGauranga987456789AAF3TrevorDavis985631458ZZMThe simple mixing *may* give us the following result

idfirst\_namelast\_namepassport\_numbersex1JaneDavis123456789AAM2JohnGauranga987456789AAF3TrevorDoe985631458ZZMYou can see the names are mixed, but all other data (`passport_number` and `sex`) is unchanged.

Dependent mixing
----------------

[](#dependent-mixing)

```
$fields = [
    ['first_name' => 'sex'],
    'last_name'
];
```

In this case in the `$table` database table all records' `first_name` and `last_name` values will be mixed randomly like in simple mixing, but `first_name` set to be dependent on the value of the `sex` field. It means on mixing the script will only select first names from other records where the value of the `sex` field is the same.

The dependent mixing *may* give us the following result from the same *starter* table

idfirst\_namelast\_namepassport\_numbersex1TrevorGauranga123456789AAM2JaneDoe987456789AAF3JohnDavis985631458ZZMAs we had only one female in our table and `first_name` is dependent on `sex`, there was nobody to mix with the first name. That is why Jane kept her first name.

CLI Usage
=========

[](#cli-usage)

The package can be used as a shell script. `$ vendor/bin/datamixer`

The script will ask the PDO dsn string, username and password for connecting to the database, than the table name and the `fileds` array.

The `fileds` array shoud be define like this: `first_name => sex, last_name`

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3074d ago

### Community

Maintainers

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

---

Top Contributors

[![rrd108](https://avatars.githubusercontent.com/u/3147489?v=4)](https://github.com/rrd108 "rrd108 (18 commits)")

---

Tags

databasemysqlphptesting-tools

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rrd108-data-mixer/health.svg)

```
[![Health](https://phpackages.com/badges/rrd108-data-mixer/health.svg)](https://phpackages.com/packages/rrd108-data-mixer)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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