PHPackages                             divineomega/uxdm - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. divineomega/uxdm

Abandoned → [jord-jd/uxdm](/?search=jord-jd%2Fuxdm)Library[PDF &amp; Document Generation](/categories/documents)

divineomega/uxdm
================

UXDM helps developers migrate data from one system or format to another.

v6.1.1(3mo ago)16426.2k↓50%81LGPL-3.0-onlyPHPPHP &gt;=7.1CI passing

Since May 12Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/Jord-JD/uxdm)[ Packagist](https://packagist.org/packages/divineomega/uxdm)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-uxdm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (88)Used By (1)

🔀 Universal Extensible Data Migrator (UXDM)
===========================================

[](#-universal-extensible-data-migrator-uxdm)

UXDM helps developers migrate data from one system or format to another.

```
// composer require jord-jd/uxdm

// Setup your source and destination objects.
// This example uses database connections, but UXDM supports many different source and destination formats.
$pdoSource = new PDOSource(new PDO('mysql:dbname=old-test;host=localhost', 'un', 'pw'), 'users');
$pdoDestination = new PDODestination(new PDO('mysql:dbname=new-test;host=localhost', 'un', 'pw'), 'new_users');

// Create a new migrator
$migrator = new Migrator;
$migrator->setSource($pdoSource)                      // Source
         ->setDestination($pdoDestination)            // Destination
         ->setFieldsToMigrate(['id', 'email', 'name']) // Fields to migrate
         ->setKeyFields(['id'])                       // Key(s) used to identify unique rows
         ->setFieldMap(['name' => 'full_name'])       // Mapping of field names, from source to destination
         ->withProgressBar()                          // Show progress bar, when run in CLI.
         ->migrate();                                 // Do the migration!
```

 [![](https://github.com/Jord-JD/uxdm/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/Jord-JD/uxdm/actions/workflows/phpunit.yml) [![](https://camo.githubusercontent.com/11d96f41e66e7235443517b7e318e4c4dc2c18e133a1b713a8d673237602e2c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4a6f72642d4a442f7578646d2e737667)](https://packagist.org/packages/jord-jd/uxdm/stats)

Installation
------------

[](#installation)

UXDM can be easily installed using Composer. Just run the following command from the root of your project.

```
composer require jord-jd/uxdm

```

If you have never used the Composer dependency manager before, head to the [Composer website](https://getcomposer.org/) for more information on how to get started.

Quick Start
-----------

[](#quick-start)

1. Create a new PHP file to contain your UXDM migration code. In this example, we'll call it `user-csv-import.php`. Remember to add `require 'vendor/autoload.php'` and relevant `use` statements, if necessary.
2. Create your source and destination objects. This example uses a CSV source and PDO (database) destination.

```
$csvSource = new CSVSource('users.csv');

$pdoDestination = new PDODestination(new PDO('mysql:dbname=test-database;host=127.0.0.1', 'root', 'password'), 'users');
```

3. Create and configure a new UXDM migrator object.

```
$migrator = new Migrator;
$migrator->setSource($csvSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->withProgressBar()
         ->migrate();
```

4. Run your newly created migration. In this example, we can just run `php user-csv-import.php` from the command line and will get a nice progress bar.

See the sections below for more information on the available source and destination objects, and more advanced usage examples.

Migrations
----------

[](#migrations)

Each UXDM migration requires a source object and at least one destination object. These determine where and how data is read and written. The UXDM package works with a variety of source and destination objects, including the following.

- PDO (PHP Database Object) Source &amp; Destination
- Eloquent (as used in Laravel) Source &amp; Destination
- Doctrine (as used in Symfony) Destination
- CSV (Comma Separated Values) Source &amp; Destination
- Excel Source &amp; Destination
- Associative Array Source &amp; Destination
- JSON Files Source &amp; Destination
- XML Source &amp; Destination
- WordPress Post Source
- WordPress User Source
- Debug Output Destination

Some of these are built-in to the core UXDM package, while others are available as separate packages.

Source and destination objects can be used in any combination. Data can be migrated from a CSV and inserted into a database, just as easily as data can be migrated from a database to a CSV.

You can also use similar source and destination objects in the same migration. For example, a common use of UXDM is to use a PDO source and PDO destination to transfer data from one database to another.

Please see the [Sources &amp; Destinations](/docs/uxdm-sources-and-destinations.md) page for more sources and destinations, and detailed documentation on their usage.

Examples
--------

[](#examples)

### Database to database migration

[](#database-to-database-migration)

An example of a basic database to database UXDM migration is shown below.

```
$pdoSource = new PDOSource(new PDO('mysql:dbname=old-test;host=127.0.0.1', 'root', 'password123'), 'users');

$pdoDestination = new PDODestination(new PDO('mysql:dbname=new-test;host=127.0.0.1', 'root', 'password456'), 'new_users');

$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->withProgressBar()
         ->migrate();
```

This migration will move the `id`, `email` and `name` fields from the `users` table in the `old-test` database to the `new_users` table in the `new-test` database, replacing any existing records with the same `id` (the key field).

### Source data validation

[](#source-data-validation)

You can use UXDM to validate the source data. If validation fails part way through a migration, the migration will halt and a `ValidationException` will be thrown. However, if `->validateBeforeMigrating()` is called, all data rows will be preemptively validated before the migration begins.

The code below shows how to validate various fields.

```
$pdoSource = new PDOSource(new PDO('mysql:dbname=old-test;host=127.0.0.1', 'root', 'password123'), 'users');

$pdoDestination = new PDODestination(new PDO('mysql:dbname=new-test;host=127.0.0.1', 'root', 'password456'), 'new_users');

$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setValidationRules([
            'id' => [new Required(), new IsNumeric()],
            'email' => [new Required(), new IsString(), new IsEmail()],
            'name' => [new Required(), new IsString()],
         ])
      // ->validateBeforeMigrating()
         ->setKeyFields(['id'])
         ->withProgressBar()
         ->migrate();
```

This migration will validate the source data matches the defined validation rules.

- 'id' must be present, and numeric.
- 'email' must be present, a string, and a correctly formatted email address.
- 'name' must be present, and a string.

UXDM uses the [Omega Validator](https://github.com/Jord-JD/omega-validator) package. See its documentation for all available validation rules.

### Mapping field names from source to destination

[](#mapping-field-names-from-source-to-destination)

This example shows how UXDM can map field names from source to destination.

```
$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->setFieldMap(['name' => 'full_name'])
         ->withProgressBar()
         ->migrate();
```

This migration will move data from the source `name` field into the destination `full_name` field, while still moving the `id` and `email` fields normally.

### Transforming data rows during migration

[](#transforming-data-rows-during-migration)

Sometimes the data you want to move from source to destination needs transforming. This can be changing existing items of data, adding new data items, or removing items you do not need.

UXDM allows you to create one or more transformer objects, and add them to the migration. See the following examples of how to use transformers to manipulate your data.

#### Changing existing data items

[](#changing-existing-data-items)

This example shows how you can transform existing data items during migration.

```
class NameCaseTransformer implements TransformerInterface
{
    public function transform(DataRow $dataRow): void
    {
        $nameDataItem = $dataRow->getDataItemByFieldName('name');
        $nameDataItem->value = ucwords(strtolower($nameDataItem->value));
    }
}

$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->addTransformer(new NameCaseTransformer())
         ->withProgressBar()
         ->migrate();
```

This migration will ensure that all name fields have consistent case.

#### Adding data items

[](#adding-data-items)

This example shows how you can add new data items while the migration is taking place.

```
class AddRandomNumberTransformer implements TransformerInterface
{
    public function transform(DataRow &$dataRow): void
    {
        $dataRow->addDataItem(new DataItem('random_number', rand(1,1000)));
    }
}

$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->addTransformer(new AddRandomNumberTransformer())
         ->withProgressBar()
         ->migrate();
```

This migration will add a random number into a field called `random_number` for each row of data. This will then be migrated to the destination database along with the other fields.

#### Removing data items

[](#removing-data-items)

This example demonstrates how data items can be removed from a data row. You may wish to do this if you want to use its value, but not actually migrate it to the destination.

```
class EmailToHashTransformer implements TransformerInterface
{
    public function transform(DataRow $dataRow): void
    {
        $emailDataItem = $dataRow->getDataItemByFieldName('email');
        $dataRow->addDataItem(new DataItem('email_hash', md5($emailDataItem->value)));
        $dataRow->removeDataItem($emailDataItem);
    }
}

$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name'])
         ->setKeyFields(['id'])
         ->addTransformer(new EmailToHashTransformer())
         ->withProgressBar()
         ->migrate();
```

This migration gets the data from the `email` field in the source, creates a new `email_hash` data item which contains an md5 of the email address, and then removes the original `email` data item. This new `email_hash` will then be migrated to the destination database along with the other fields, excluding the removed `email` field.

### Skipping data rows during migration

[](#skipping-data-rows-during-migration)

Sometimes you may wish to skip certain rows during a migration (for example, to filter out unwanted records). You can do this by providing a callback using `setSkipIfTrueCheck()`. If your callback returns `true` for a given data row, that row will be skipped and not sent to the destination(s).

```
$migrator = new Migrator;
$migrator->setSource($pdoSource)
         ->setDestination($pdoDestination)
         ->setFieldsToMigrate(['id', 'email', 'name', 'rank'])
         ->setKeyFields(['id'])
         ->setSkipIfTrueCheck(function (DataRow $dataRow) {
             $rankDataItem = $dataRow->getDataItemByFieldName('rank');
             return $rankDataItem->value !== 'Captain';
         })
         ->withProgressBar()
         ->migrate();
```

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 95.4% 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 ~40 days

Recently: every ~521 days

Total

80

Last Release

91d ago

Major Versions

v1.23.0 → v2.0.02018-04-20

v2.7.1 → v3.0.02019-04-23

v3.5.4 → v4.0.02020-05-09

v4.0.2 → v5.0.02026-02-14

v5.0.0 → v6.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (185 commits)")[![dextermb](https://avatars.githubusercontent.com/u/6137789?v=4)](https://github.com/dextermb "dextermb (6 commits)")[![kirsty-gasston](https://avatars.githubusercontent.com/u/12949343?v=4)](https://github.com/kirsty-gasston "kirsty-gasston (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

arraycsvdata-conversiondata-migrationdata-migratorjsonmarkdownpdophpphp-libraryuxdmwordpressxml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/divineomega-uxdm/health.svg)

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

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[techdivision/import

A library supporting generic Magento 2 import functionality

127200.3k9](/packages/techdivision-import)

PHPackages © 2026

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