Download the PHP package utopia-php/replication without Composer
On this page you can find all versions of the php package utopia-php/replication. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download utopia-php/replication
More information about utopia-php/replication
Files in utopia-php/replication
Package replication
Short Description A Swoole-native MySQL binlog replication reader for streaming row changes (CDC)
License MIT
Informations about the package replication
Utopia Replication
[!IMPORTANT] This repository is a read-only mirror of the utopia-php monorepo. Development happens in
packages/replication— please open issues and pull requests there.
Utopia Replication is a Swoole-native MySQL binlog reader. It streams row-level changes (change data capture) from a MySQL server over the replication protocol, so a consumer can react to writes — invalidate caches, build projections, fan out events — by tailing a server locally instead of relying on application-level messaging. This library is maintained by the Appwrite team.
Although this library is part of the Utopia Framework project it is dependency free and can be used as standalone with any other PHP project or framework.
Getting started
Install using Composer:
System requirements
Utopia Replication requires PHP 8.3 or later, and the Swoole extension (>=6.0) for coroutine socket I/O. The OpenSSL extension is required for caching_sha2_password full authentication and TLS.
Source server
The MySQL source must be configured for GTID-based row replication:
binlog_row_metadata = FULL lets column names ride along in the binlog. When it
is MINIMAL (the MySQL default, and what some managed providers are fixed to)
the reader resolves names from INFORMATION_SCHEMA over a second connection
instead — no configuration change required.
The connecting user needs the REPLICATION SLAVE and REPLICATION CLIENT privileges.
Usage
The reader runs inside a Swoole coroutine; getChanges() blocks (yielding the
coroutine) while waiting for events. The GTID checkpoint advances on transaction
commit, so a crash mid-transaction re-streams it — treat changes as idempotent.
Reading from a binlog file
Decoding and transport are separate: a Decoder turns raw binlog events into
Changes, and a Transport supplies those events. The MySQL source above is a
live MySQL\Connection transport wired to a Decoder; swap in a MySQL\File
transport to decode an archived binlog file — the same bytes mysqlbinlog --raw
writes, or a segment pulled from object storage — with no server and no
replication privileges:
Scope
Deliberately minimal: MySQL 8, ROW-format binlog, and the event types needed for
CDC (TABLE_MAP, WRITE/UPDATE/DELETE_ROWS, GTID, ROTATE, XID). JSON column values
are skipped (bytes advanced, not decoded). Column names come from FULL row
metadata when available, otherwise from a single cached INFORMATION_SCHEMA
lookup per table.
Tests
Copyright and license
The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php
All versions of replication with dependencies
ext-swoole Version *