Add PHP port of Etherpad Lite Changeset library with pad writer script#136
Draft
Add PHP port of Etherpad Lite Changeset library with pad writer script#136
Conversation
Co-authored-by: Gared <913630+Gared@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add changeset library integration for Etherpad Lite
Add PHP port of Etherpad Lite Changeset library
Mar 9, 2026
Owner
|
@copilot please use the code in this pull request in a proof-of-concept php script to connect to a pad of an etherpad instance and add the text "Hello world" in the middle to the text |
…ion for wire protocol Co-authored-by: Gared <913630+Gared@users.noreply.github.com>
Author
Added Usage: php bin/etherpad-writer.php https://etherpad.example.com my-padHow it works:
Also fixed |
Copilot
AI
changed the title
Add PHP port of Etherpad Lite Changeset library
Add PHP port of Etherpad Lite Changeset library with pad writer script
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a PHP implementation of the Etherpad Lite Changeset library, enabling clients to construct and apply changesets to write text into pads programmatically.
New classes (
src/Changeset/)Op— single changeset operation: keep (=), insert (+), delete (-)AttributePool— attribute interning (key/value pairs ↔ numeric IDs)StringIterator/StringAssembler— low-level string processing primitivesOpAssembler/MergingOpAssembler/SmartOpAssembler— Op serialization with progressive merging/optimizationBuilder— fluent API for incrementally composing changesetsChangeset— core static methods:pack,unpack,applyToText,makeSplice,compose,identity,moveOpsToNewPool, etc.Proof-of-concept script (
bin/etherpad-writer.php)A CLI script demonstrating the Changeset library by connecting to a live Etherpad instance and inserting "Hello world" in the middle of an existing pad's text:
The script follows the full Etherpad Socket.IO collab protocol:
CLIENT_READYCLIENT_VARS— extracts current text and head revision numberChangeset::makeSplice()inserting at the midpointUSER_CHANGESwrapped in aCOLLABROOMmessageACCEPT_COMMITconfirmation from the serverUsage
The
Builderclass offers a more ergonomic interface for keep/insert/remove sequences, matching the format expected by the Etherpad Socket.IO collab protocol.Wire protocol compatibility
AttributePool::toJsonable()returnsnumToAttribas a\stdClassso thatjson_encode()always produces a JSON object ({}) rather than a JSON array ([]). This matches what the Etherpad server expects.fromJsonable()transparently accepts both\stdClassand plain arrays.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.