PHPackages                             netglue/prismic-migration-client - 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. netglue/prismic-migration-client

ActiveLibrary

netglue/prismic-migration-client
================================

1.0.x-dev(1y ago)0101[1 PRs](https://github.com/netglue/prismic-migration-client/pulls)MITPHPPHP ~8.3 || ~8.4CI passing

Since Feb 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/netglue/prismic-migration-client)[ Packagist](https://packagist.org/packages/netglue/prismic-migration-client)[ RSS](/packages/netglue-prismic-migration-client/feed)WikiDiscussions 1.0.x Synced 1mo ago

READMEChangelogDependencies (17)Versions (2)Used By (0)

Prismic Migration API PHP Client
================================

[](#prismic-migration-api-php-client)

This is a client for Prismic.io's Migration API.

You can find documentation on the API at [prismic.io/docs/migration-api-technical-reference](https://prismic.io/docs/migration-api-technical-reference)

Install
-------

[](#install)

```
composer require netglue/prismic-migration-client
```

Usage
-----

[](#usage)

You'll need to construct the concrete client yourself with all of its required dependencies:

- A [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client such as [php-http/curl-client](https://github.com/php-http/curl-client)
- [PSR-7](https://www.php-fig.org/psr/psr-7/) implementations with [PSR-17](https://www.php-fig.org/psr/psr-17/) Stream Factory, Request Factory and Uri Factory such as [laminas/laminas-diactoros](https://github.com/laminas/laminas-diactoros/)

You will need a write api token for the target repo and one of the "Demo API Keys" whatever the fuck they are. You can find them here:

Assuming you have a PSR-11 container set up, you might be able to do something like this in a factory:

```
use Prismic\Migration\MigrationClientImplementation;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;

$client = new MigrationClientImplementation(
    'some-write-token',
    'some-repo-name',
    'some-demo-api-key',
    $container->get(ClientInterface::class),
    $container->get(RequestFactoryInterface::class),
    $container->get(UriFactoryInterface::class),
    $container->get(StreamFactoryInterface::class),
);
```

There's also a client shipped for the document read api which is a simplified client designed for fetching the source documents with minimum of fuss and in an easily serializable state.

```
use Prismic\Migration\DocumentClientImplementation;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;

$client = new DocumentClientImplementation(
    'some-read-token-or-null', // Token can be null here if your read api doesn't require one
    'repo-name',
    $container->get(ClientInterface::class),
    $container->get(RequestFactoryInterface::class),
    $container->get(UriFactoryInterface::class),
);
```

Basic Functionality
-------------------

[](#basic-functionality)

### Create Document

[](#create-document)

Create a document using the shipped value object `MigrationDocument`:

```
use Prismic\Migration\DocumentClient;
use Prismic\Migration\MigrationClient;
use Prismic\Migration\Model\MigrationDocument;

$readClient = $container->get(DocumentClient::class);
assert($readClient instanceof DocumentClient);

$migrationClient = $container->get(MigrationClient::class);
assert($migrationClient instanceof MigrationClient);

$document = $readClient->findById('some-document-id');

$migrationDoc = new MigrationDocument(
    'Make up a title or figure it out from content',
    $document->type,
    $document->uid,
    $document->lang,
    $document->data,
);

$result = $migrationClient->createDocument($migrationDoc);
```

### Update Already Migrated Document

[](#update-already-migrated-document)

```
use Prismic\Migration\MigrationClient;
use Prismic\Migration\Model\Document;
use Prismic\Migration\Model\MigrationDocumentPatch;
use Prismic\Migration\Model\MigrationResult;

assert($migrationClient instanceof MigrationClient);
assert($document instanceof Document);
assert($result instanceof MigrationResult);

$patch = new MigrationDocumentPatch(
    $result->id,
    $document->uid, // No idea if this can be mutated or not
    $document->data, // The entire payload of the source document is required
    $document->tags, // You must repeat existing tags or they will be removed
    'Updated Title', // Or null to leave it alone
);

$result = $migrationClient->updateDocument($patch);
```

Patching docs seems pointless given its design - you're better off sending the data you want first time with `createDocument`.

### Document Read API Client

[](#document-read-api-client)

The read-api client has two methods:

- `findById(non-empty-string): Document`
- `findAll(): list`

It will use the current `master` ref, so you'll need to ensure that anything you want to migrate is published already.

Contributing
------------

[](#contributing)

Please feel free to get involved with development. The project uses PHPUnit for tests, and [Psalm](https://psalm.dev) and [PHPStan](https://phpstan.org) for static analysis. CI should have your back if you want to submit a feature or fix ;)

License
-------

[](#license)

[MIT Licensed](LICENSE.md).

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance68

Regular maintenance activity

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

444d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6c21b0de8cc9938916a186f5f2ed0bee90a4e23e0b29cf7b9c18bfe99067f9b?d=identicon)[netglue](/maintainers/netglue)

---

Top Contributors

[![gsteel](https://avatars.githubusercontent.com/u/2803720?v=4)](https://github.com/gsteel "gsteel (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/netglue-prismic-migration-client/health.svg)

```
[![Health](https://phpackages.com/badges/netglue-prismic-migration-client/health.svg)](https://phpackages.com/packages/netglue-prismic-migration-client)
```

###  Alternatives

[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[neos/flow

Flow Application Framework

862.0M449](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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