{"id":33991504,"url":"https://github.com/cloudblue/connect-php-sdk-migration-framework","last_synced_at":"2026-03-08T23:32:21.953Z","repository":{"id":56949625,"uuid":"183177522","full_name":"cloudblue/connect-php-sdk-migration-framework","owner":"cloudblue","description":"Migration framework for the CloudBlue Connect PHP SDK for the migration scenarios automation","archived":false,"fork":false,"pushed_at":"2019-05-15T07:36:34.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-14T18:54:36.135Z","etag":null,"topics":["cloudblue","cloudblueconnect","connect","migration"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudblue.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":"2019-04-24T07:55:03.000Z","updated_at":"2025-08-24T13:34:50.000Z","dependencies_parsed_at":"2022-08-21T07:50:21.424Z","dependency_job_id":null,"html_url":"https://github.com/cloudblue/connect-php-sdk-migration-framework","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/cloudblue/connect-php-sdk-migration-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudblue%2Fconnect-php-sdk-migration-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudblue%2Fconnect-php-sdk-migration-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudblue%2Fconnect-php-sdk-migration-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudblue%2Fconnect-php-sdk-migration-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudblue","download_url":"https://codeload.github.com/cloudblue/connect-php-sdk-migration-framework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudblue%2Fconnect-php-sdk-migration-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30276941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T20:45:49.896Z","status":"ssl_error","status_checked_at":"2026-03-08T20:45:49.525Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cloudblue","cloudblueconnect","connect","migration"],"created_at":"2025-12-13T06:49:58.714Z","updated_at":"2026-03-08T23:32:21.945Z","avatar_url":"https://github.com/cloudblue.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connect Migration Middleware\n\n[![Build Status](https://travis-ci.com/ingrammicro/connect-php-sdk-migration-framework.svg?branch=master)](https://travis-ci.com/ingrammicro/connect-php-sdk-migration-framework) [![Latest Stable Version](https://poser.pugx.org/apsconnect/connect-sdk-migration-framework/v/stable)](https://packagist.org/packages/apsconnect/connect-sdk-migration-framework) [![License](https://poser.pugx.org/apsconnect/connect-sdk-migration-framework/license)](https://packagist.org/packages/apsconnect/connect-sdk-migration-framework) [![codecov](https://codecov.io/gh/ingrammicro/connect-php-sdk-migration-framework/branch/master/graph/badge.svg)](https://codecov.io/gh/ingrammicro/connect-php-sdk-migration-framework)\n\nSmall middleware to ease the service migration from legacy to Connect\n\n## Installation\n\nInstall via ***composer***:\n\n```json\n{\n    \"require\": {\n      \"apsconnect/connect-sdk-migration-framework\": \"*\"\n    }\n}\n```\n\n## Usage \n\nOnce we have the package installed we need to create a new service provider to inject the middleware \ninto our connector. We need to provide some basic configuration to our migrations service in order to \nproperly migrate the incoming old data.\n\n### Configuration parameters\n\n| Parameter       | Type                      | Description                           |\n| --------------- | ------------------------- | ------------------------------------- |\n| logger          | `Psr\\Log\\LoggerInterface` | The logger instance of our connector. |\n| migrationFlag   | `string`                  | The name of the Connect parameter that stores the legacy data in json format. Default value is `migration_info`|\n| serialize       | `bool`                    | If true will automatically serialize any non-string value in the migration data on direct assignation flow. Default value is `false` |\n| validation      | `callable`                | Custom validation function. Not defined by default. |\n| onSuccess       | `callable`                | Custom function to execute on migration success. Not defined by default. |\n| onFail          | `callable`                | Custom function to execute on migration fail. Not defined by default. |\n| transformations | `array`                   | Assoc array with the connect param id as key and the rule to process the parameter value from the legacy data. Default value is an empty array. |\n\nInput parameters: \n\n- `validation`: `$migrationData`, `Request $request`, `Config $config`, `LoggerInterface $logger`\n- `onSuccess`: `$migrationData`, `Request $request`, `Config $config`, `LoggerInterface $logger`\n- `onFail`: `$migrationData`, `Request $request`, `Config $config`, `LoggerInterface $logger`, `MigrationAbortException $e`\n- `transformations`: `$migrationData`, `Request $request`, `Config $config`, `LoggerInterface $logger`\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse GuzzleHttp\\Client;\nuse Connect\\Config;\nuse Connect\\Request;\nuse Connect\\Fail;\nuse Connect\\Middleware\\Migration\\Handler as MigrationHandler;\nuse Connect\\Runtime\\ServiceProvider;\nuse Pimple\\Container;\nuse Psr\\Log\\LoggerInterface;\nuse Connect\\Middleware\\Migration\\Exceptions\\MigrationParameterFailException;\nuse Connect\\Middleware\\Migration\\Exceptions\\MigrationAbortException;\n\n/**\n * Class MigrationServiceProvider\n * @package App\\Providers\n */\nclass MigrationServiceProvider extends ServiceProvider\n{\n    /**\n     * Create a Migrate middleware\n     * @param Container $container\n     * @return MigrationHandler\n     */\n    public function register(Container $container)\n    {\n        return new MigrationHandler([\n            'logger' =\u003e $container['logger'],\n            'config' =\u003e $container['config'],\n            'transformations' =\u003e [\n                'email' =\u003e function ($migrationData, Request $request, Config $config, LoggerInterface $logger) {\n                    $logger-\u003einfo(\"[MIGRATION::{$request-\u003eid}] Processing teamAdminEmail parameter.\");\n                    \n                    $client = new Client();\n                    $response = $client-\u003erequest('GET', strtr($config-\u003eservice-\u003emigration-\u003eurl, [\n                        '{instance}' =\u003e $migrationData-\u003einstance,\n                        '{subscription}' =\u003e $migrationData-\u003esubscription\n                    ]) . '/teamAdminEmail', [\n                        'headers' =\u003e [\n                            'http_errors' =\u003e false,\n                            'Authorization' =\u003e 'Basic ' . $migrationData-\u003etoken\n                        ]\n                    ]);\n                    \n                    if ($response-\u003egetStatusCode() !== 200) {\n                        throw new MigrationParameterFailException(\"Missing field teamAdminEmail\", $response-\u003egetStatusCode());\n                    }\n                    \n                    $data = json_decode($response-\u003egetBody()-\u003egetContents());\n                    \n                    if(empty($data-\u003evalue)) {\n                        throw new MigrationParameterFailException(\"Missing field teamAdminEmail.\", 400);\n                    }\n                    \n                    if(!filter_var($data-\u003evalue, FILTER_VALIDATE_EMAIL)) {\n                        throw new MigrationParameterFailException(\"Wrong field teamAdminEmail must be an email.\", 400);\n                    }\n                    \n                    return strtolower($data-\u003evalue);\n                },\n                'team_id' =\u003e function ($migrationData, Request $request, Config $config, LoggerInterface $logger) {\n                    $logger-\u003einfo(\"[MIGRATION::{$request-\u003eid}] Processing teamId parameter.\");\n                    \n                    $client = new Client();\n                    $response = $client-\u003erequest('GET', strtr($config-\u003eservice-\u003emigration-\u003eurl, [\n                        '{instance}' =\u003e $migrationData-\u003einstance,\n                        '{subscription}' =\u003e $migrationData-\u003esubscription\n                    ]) . '/teamId', [\n                        'headers' =\u003e [\n                            'http_errors' =\u003e false,\n                            'Authorization' =\u003e 'Basic ' . $migrationData-\u003etoken\n                        ]\n                    ]);\n                    \n                    if ($response-\u003egetStatusCode() !== 200) {\n                        throw new MigrationParameterFailException(\"Missing field teamId\", $response-\u003egetStatusCode());\n                    }\n                    \n                    $data = json_decode($response-\u003egetBody()-\u003egetContents());\n                    \n                    if(empty($data-\u003evalue)) {\n                        throw new MigrationParameterFailException(\"Missing field teamId.\", 400);\n                    }\n                    \n                    return strtolower($data-\u003evalue);\n                },\n                'team_name' =\u003e function ($migrationData, Request $request, Config $config, LoggerInterface $logger) {\n                    $logger-\u003einfo(\"[MIGRATION::{$request-\u003eid}] Processing teamName parameter.\");\n                    \n                    $client = new Client();\n                    $response = $client-\u003erequest('GET', strtr($config-\u003eservice-\u003emigration-\u003eurl, [\n                        '{instance}' =\u003e $migrationData-\u003einstance,\n                        '{subscription}' =\u003e $migrationData-\u003esubscription\n                    ]) . '/teamName', [\n                        'headers' =\u003e [\n                            'http_errors' =\u003e false,\n                            'Authorization' =\u003e 'Basic ' . $migrationData-\u003etoken\n                        ]\n                    ]);\n                    \n                    if ($response-\u003egetStatusCode() !== 200) {\n                        throw new MigrationParameterFailException(\"Missing field teamName\", $response-\u003egetStatusCode());\n                    }\n                    \n                    $data = json_decode($response-\u003egetBody()-\u003egetContents());\n                    \n                    if(empty($data-\u003evalue)) {\n                        throw new MigrationParameterFailException(\"Missing field teamName.\", 400);\n                    }\n                    \n                    return ucwords($data-\u003eteamName);\n                },\n            ],\n            'onSuccess' =\u003e function($migrationData, Request $request, Config $config, LoggerInterface $logger) {\n                $logger-\u003einfo(\"Migration for request {$request-\u003eid} successful!\");\n            },\n            'onFail' =\u003e function($migrationData, Request $request, Config $config, LoggerInterface $logger, MigrationAbortException $e) {\n                throw new Fail(\"Failing request {$request-\u003eid} due: \" . $e-\u003egetMessage());\n            }\n        ]);\n    }\n}\n```\n\nNext we need to add this service provider to our configuration json:\n\n```json \n{\n  \"runtimeServices\": {\n    \"migration\": \"\\\\App\\\\Providers\\\\MigrationServiceProvider\",\n  }\n}\n```\n\nAnd in our `ProductFulfillment.php`:\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Connect\\Logger;\nuse Connect\\Middleware\\Migration\\Handler;\nuse Connect\\FulfillmentAutomation;\n\n/**\n * Class ProductFulfillment\n * @package App\n * @property Logger $logger\n * @property Handler $migration\n */\nclass ProductFulfillment extends FulfillmentAutomation\n {\n    public function processRequest($request)\n    {\n        switch ($request-\u003etype) {\n            case \"purchase\":\n                \n                $request = $this-\u003emigration-\u003emigrate($request);\n                \n                // the migrate() method returns a new request object with the\n                // migrated data populated, we only need to update the params \n                // and approve the fulfillment to complete the migration.\n                \n                $this-\u003eupdateParameters($request, $request-\u003easset-\u003eparams);\n                \n                // more code...\n        }\n\n    }\n    \n    public function processTierConfigRequest($tierConfigRequest)\n    {\n        // NOT MIGRABLE! (YET)\n    }\n}\n```\n\n### Exceptions\n\nThe connect migration middleware uses two different exceptions:\n\n| Exception | Description | \n| --------- | ------------------------------ | \n| `MigrationParameterFailException` | Can be thrown if any parameter fails on validation and/or transformation, an error will be logged for that parameter, the migration will fail, the fulfillment will be skipped. | \n| `MigrationAbortException` | The migration will directly fail, the fulfillment will be skipped. | \n| `MigrationParameterPassException` | Parameter process will be omitted, other parameters will continue normally. | \n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudblue%2Fconnect-php-sdk-migration-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudblue%2Fconnect-php-sdk-migration-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudblue%2Fconnect-php-sdk-migration-framework/lists"}