How wordpress/reprint works
Purpose and entry points
Reprint is a PHP 7.4+ WordPress migration system: an exporter installed on a source WordPress site exposes a resumable authenticated HTTP API; an importer clones files, database, and runtime assumptions to a target. Primary CLI entrypoint: packages/reprint-importer/src/import.php, distributed as a PHAR via bin/build-reprint-phar.sh. importer/import.php is a compatibility wrapper. The source plugin entrypoint is reprint-exporter-wp/index.php.
Export server and protocol
The reusable export engine implements HTTP serving, HMAC authentication, staged endpoints, and resumable streaming protocols. It produces filesystem indexes/content and MySQL SQL dumps, backed by WordPress $wpdb or PDO/SQLite adapters.
• packages/reprint-exporter/src/export.php
• packages/reprint-exporter/src/class-http-server.php
• packages/reprint-exporter/src/class-staged-push-stream-protocol.php
• packages/reprint-exporter/src/class-file-tree-producer.php
• packages/reprint-exporter/src/class-mysql-dump-producer.php
The WordPress plugin packages this engine and exposes its site-export route. Source and target share an HMAC secret, establishing the trust boundary around remote migration data.
• reprint-exporter-wp/index.php
• reprint-exporter-wp/wordpress/site-export.php
• packages/reprint-exporter/src/class-hmac-server.php
Import orchestration and durable state
The importer CLI coordinates preflight, file sync, database pull/apply, runtime generation, and high-level pull variants. Its persistent import state/status enables restart after interruption, delta sync, cursored transfer, and crash recovery; state is the boundary between independent command invocations.
• packages/reprint-importer/src/import.php
• packages/reprint-importer/src/lib/state/class-import-state.php
• packages/reprint-importer/bin/reprint-importer
File migration pipeline
File transfer is a staged remote-index → local diff → download-list → streamed-body workflow. It supports filtering, path selection, resumable cursors, integrity/error handling, deletion/type changes, and symlink-aware reconstruction. Push-related client components batch and size staged stream requests; pull handles remote retrieval.
• packages/reprint-importer/src/lib/pull/class-pull.php
• packages/reprint-importer/src/lib/upload/class-staged-push-stream-client.php
• packages/reprint-importer/src/lib/upload/class-push-request-sizer.php
• packages/reprint-importer/src/lib/push/class-push-journal.php
Database transfer and transformation
The exporter streams SQL while the importer can persist it, emit it, or execute it directly against MySQL. db-apply targets MySQL or SQLite and rewrites site URLs safely across SQL literals, serialized PHP, JSON, and structured WordPress data. SQLite support depends on the bundled database-integration library.
• packages/reprint-importer/src/lib/mysql-query-stream/class-wp-mysql-fast-query-stream.php
• packages/reprint-importer/src/lib/url-rewrite/class-sql-statement-rewriter.php
• packages/reprint-importer/src/lib/url-rewrite/class-structured-data-url-rewriter.php
• packages/reprint-exporter/src/class-sqlite-driver-pdo.php
• lib/sqlite-database-integration
Host analysis and target runtime generation
Preflight gathers remote environment/layout data. Source-host analyzers translate it into a declarative runtime manifest; target runtime appliers render runtime PHP plus launch/server configuration. These are intentionally decoupled extension points: hosts include WP Cloud, SiteGround, and default; targets include PHP built-in, nginx/PHP-FPM, and Playground CLI.
• packages/reprint-importer/src/lib/host/class-runtime-manifest.php
• packages/reprint-importer/src/lib/host/analyzers/class-wpcloud-host-analyzer.php
• packages/reprint-importer/src/lib/target-runtime/class-php-builtin-applier.php
• packages/reprint-importer/src/lib/target-runtime/class-nginx-fpm-applier.php
• packages/reprint-importer/src/lib/target-runtime/class-playground-cli-applier.php
Distribution and optional UI
The repository publishes separate Composer packages, a WordPress plugin ZIP, and a self-contained PHAR. A small PHP UI provides migration-oriented browser endpoints and Playground upload proxy support; it is not the core migration path.
• composer.json
• box.json
• reprint-ui/index.php
• reprint-ui/reprint-import.php
Main entry points: import.php Importer CLI · export.php Export engine · class-pull.php Pull pipeline · class-http-server.php HTTP server
Components 20
Source WordPress
Authenticated export surface.
- Exporter WP plugin
reprint-exporter-wp/index.php - Site export route
reprint-exporter-wp/wordpress/site-export.php - Export engine · Serves staged filesystem and database exports.
packages/reprint-exporter/src/export.php - HTTP server
packages/reprint-exporter/src/class-http-server.php - HMAC authentication · Shared secret authenticates migration requests.
packages/reprint-exporter/src/class-hmac-server.php - Staged stream protocol
packages/reprint-exporter/src/class-staged-push-stream-protocol.php - File tree producer
packages/reprint-exporter/src/class-file-tree-producer.php - MySQL dump producer
packages/reprint-exporter/src/class-mysql-dump-producer.php
Importer
CLI orchestration and durable migration pipeline.
- Importer CLI · Coordinates preflight, pull, apply, and runtime generation.
packages/reprint-importer/src/import.php - Import state · Persists status and cursors across command invocations.
packages/reprint-importer/src/lib/state/class-import-state.php - Pull pipeline · Fetches remote indexes, diffs, and streamed file bodies.
packages/reprint-importer/src/lib/pull/class-pull.php - Staged push client · Batches and sizes staged transfer requests.
packages/reprint-importer/src/lib/upload/class-staged-push-stream-client.php - Push journal
packages/reprint-importer/src/lib/push/class-push-journal.php - SQL query stream
packages/reprint-importer/src/lib/mysql-query-stream/class-wp-mysql-fast-query-stream.php - SQL URL rewriter · Safely rewrites SQL literals and structured WordPress data.
packages/reprint-importer/src/lib/url-rewrite/class-sql-statement-rewriter.php - Runtime manifest · Decouples source-host analysis from target application.
packages/reprint-importer/src/lib/host/class-runtime-manifest.php
Target Runtime
Generated runtime and applied data.
- Target runtime appliers · Renders PHP and launch configuration for supported targets.
packages/reprint-importer/src/lib/target-runtime/class-php-builtin-applier.php - Target site · Receives synchronized files, database, and generated configuration.
Distribution & UI
Packaging and optional browser interface.
- Package & PHAR build · Publishes Composer packages, plugin ZIP, and importer PHAR.
box.json - Migration UI · Browser endpoints and Playground upload proxy.
reprint-ui/index.php
Connections 22
- Exporter WP plugin → Site export route: registers
- Site export route → Export engine: invokes
- Export engine → HTTP server: serves through
- HTTP server → HMAC authentication: authenticates with
- Export engine → Staged stream protocol: uses
- Export engine → File tree producer: exports files
- Export engine → MySQL dump producer: streams SQL
- Importer CLI → Import state: persists progress
- Importer CLI → Pull pipeline: orchestrates
- Pull pipeline → HTTP server: retrieves export
- Pull pipeline → Staged stream protocol: resumes streams
- Staged push client → Staged stream protocol: sends staged requests
- Importer CLI → Push journal: records transfers
- Importer CLI → SQL query stream: pulls or applies SQL
- SQL query stream → SQL URL rewriter: transforms statements
- SQL URL rewriter → Target site: applies database
- Importer CLI → Runtime manifest: builds after preflight
- Runtime manifest → Target runtime appliers: drives
- Target runtime appliers → Target site: generates runtime
- Pull pipeline → Target site: reconstructs files
- Package & PHAR build → Importer CLI: bundles as PHAR
- Migration UI → Importer CLI: supports migration flow