{"id":19845232,"url":"https://github.com/rapidwebltd/uxdm","last_synced_at":"2025-08-31T09:44:00.778Z","repository":{"id":62533308,"uuid":"90974025","full_name":"rapidwebltd/uxdm","owner":"rapidwebltd","description":"🔀 UXDM helps developers migrate data from one system or format to another.","archived":false,"fork":false,"pushed_at":"2018-04-16T10:42:55.000Z","size":189,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-07T06:18:02.292Z","etag":null,"topics":["data-migration","php","php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapidwebltd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-11T11:56:56.000Z","updated_at":"2020-08-17T09:45:27.000Z","dependencies_parsed_at":"2022-11-02T16:01:06.157Z","dependency_job_id":null,"html_url":"https://github.com/rapidwebltd/uxdm","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/rapidwebltd/uxdm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fuxdm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fuxdm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fuxdm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fuxdm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapidwebltd","download_url":"https://codeload.github.com/rapidwebltd/uxdm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fuxdm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272965456,"owners_count":25023071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-migration","php","php-library"],"created_at":"2024-11-12T13:06:57.922Z","updated_at":"2025-08-31T09:44:00.713Z","avatar_url":"https://github.com/rapidwebltd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔀 Universal Extensible Data Migrator (UXDM)\n\n[![Build Status](https://travis-ci.org/rapidwebltd/uxdm.svg?branch=master)](https://travis-ci.org/rapidwebltd/uxdm)\n[![Coverage Status](https://coveralls.io/repos/github/rapidwebltd/uxdm/badge.svg?branch=master)](https://coveralls.io/github/rapidwebltd/uxdm?branch=master)\n[![StyleCI](https://styleci.io/repos/90974025/shield?branch=master)](https://styleci.io/repos/90974025)\n![Packagist](https://img.shields.io/packagist/dt/rapidwebltd/uxdm.svg)\n\nUXDM helps developers migrate data from one system or format to another.\n\n## Installation\n\nUXDM can be easily installed using Composer. Just run the following command from the root of your project.\n\n```\ncomposer require rapidwebltd/uxdm\n```\n\nIf 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.\n\n## Migrations\n\nEach 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 comes with a variety of source and destination objects, including the following.\n\n* PDO (PHP Database Object) Source \u0026 Destination\n* CSV (Comma Seperated Values) Source \u0026 Destination\n* Associative Array Source \u0026 Destination\n* JSON Files Source \u0026 Destination\n* XML Source \u0026 Destination\n* WordPress Post Source\n* WordPress User Source\n* Debug Output Destination\n\nSource 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.\n\nYou 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. \n\nPlease see the [Sources \u0026 Destinations](/docs/uxdm-sources-and-destinations.md) page for more detailed documentation on their usage.\n\n## Examples\n\n### Database to database migration\n\nAn example of a basic database to database UXDM migration is shown below.\n\n```php\n$pdoSource = new PDOSource(new PDO('mysql:dbname=old-test;host=127.0.0.1', 'root', 'password123'), 'users');\n\n$pdoDestination = new PDODestination(new PDO('mysql:dbname=new-test;host=127.0.0.1', 'root', 'password456'), 'new_users');\n\n$migrator = new Migrator;\n$migrator-\u003esetSource($pdoSource)\n         -\u003esetDestination($pdoDestination)\n         -\u003esetFieldsToMigrate(['id', 'email', 'name'])\n         -\u003esetKeyFields(['id'])\n         -\u003emigrate();\n```\n\nThis migration will move the `id`, `email` and `name` fields from the 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).\n\n### Mapping field names from source to destination\n\nThis examples shows how UXDM can map field names from source to destination.\n\n```php\n$migrator = new Migrator;\n$migrator-\u003esetSource($pdoSource)\n         -\u003esetDestination($pdoDestination)\n         -\u003esetFieldsToMigrate(['id', 'email', 'name'])\n         -\u003esetKeyFields(['id'])\n         -\u003esetFieldMap(['name' =\u003e 'full_name'])\n         -\u003emigrate();\n```\n\nThis migration will move data from the source `name` field into the destination `full_name` field, while still moving the `id` and `email` fields normally.\n\n### Modifying data items during migration\n\nThe following example shows how you can use UXDM to modify items of data during the migration process.\n\n```php\n$migrator = new Migrator;\n$migrator-\u003esetSource($pdoSource)\n         -\u003esetDestination($pdoDestination)\n         -\u003esetFieldsToMigrate(['id', 'email', 'name'])\n         -\u003esetKeyFields(['id'])\n         -\u003esetDataItemManipulator(function($dataItem) {\n            if ($dataItem-\u003efieldName=='name') {\n                $dataItem-\u003evalue = strtoupper($dataItem-\u003evalue);\n            }\n         })\n         -\u003emigrate();\n```\n\nThis migration will move user data between two databases. However, it will also convert the value in the `name` field to uppercase.\n\n### Modifying data rows during migration\n\n#### Adding data items\n\nThis examples shows how UXDM can modify each row of data while the migration is taking place.\n\n```php\n$migrator = new Migrator;\n$migrator-\u003esetSource($pdoSource)\n         -\u003esetDestination($pdoDestination)\n         -\u003esetFieldsToMigrate(['id', 'email', 'name'])\n         -\u003esetKeyFields(['id'])\n         -\u003esetDataRowManipulator(function($dataRow) {\n            $dataRow-\u003eaddDataItem(new DataItem('random_number', rand(1,1000)));\n         })\n         -\u003emigrate();\n```\n\nThis 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.\n\n#### Removing data items\n\nThis 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.\n\n```php\n$migrator = new Migrator;\n$migrator-\u003esetSource($pdoSource)\n         -\u003esetDestination($pdoDestination)\n         -\u003esetFieldsToMigrate(['id', 'email', 'name'])\n         -\u003esetKeyFields(['id'])\n         -\u003esetDataRowManipulator(function($dataRow) {\n            $emailDataItem = $dataRow-\u003egetDataItemByFieldName('email');\n            $dataRow-\u003eaddDataItem(new DataItem('email_hash', md5($emailDataItem-\u003evalue)));\n            $dataRow-\u003eremoveDataItem($emailDataItem);\n         })\n         -\u003emigrate();\n```\n\nThis 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fuxdm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidwebltd%2Fuxdm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fuxdm/lists"}