PHPackages                             wp-php-toolkit/merge - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wp-php-toolkit/merge

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wp-php-toolkit/merge
====================

Merge component for WordPress with configurable diffing and merging strategies.

v0.8.1(1mo ago)1104GPL-2.0-or-laterPHPPHP &gt;=7.2

Since May 20Pushed 1mo agoCompare

[ Source](https://github.com/wp-php-toolkit/merge)[ Packagist](https://packagist.org/packages/wp-php-toolkit/merge)[ Docs](https://wordpress.github.io/php-toolkit/reference/merge.html)[ RSS](/packages/wp-php-toolkit-merge/feed)WikiDiscussions trunk Synced today

READMEChangelogDependencies (22)Versions (49)Used By (0)

   slug merge   title Merge   install wp-php-toolkit/merge   see\_also    git | Git | Merge file contents discovered through repository history.

 markdown | Markdown | Resolve file-based editorial workflows before converting to blocks.

 dataliberation | DataLiberation | Make content synchronization conflicts visible.

    Three-way merge and diff. Pluggable differ + merger + optional validator.

Why this exists
---------------

[](#why-this-exists)

Content synchronization needs more than "last write wins." A Markdown file changes in Git while the same post changes in WordPress. A generated config changes through both a CLI tool and a UI. In those cases you need a common ancestor, two edited versions, and a way to explain conflicts to a human.

The Merge component provides the diff and three-way merge primitives used by those workflows. The default examples are line-oriented because that is the most familiar shape, but the strategy is intentionally pluggable: choose the differ, choose the merger, and optionally validate the merged result before accepting it.

Use the merge result to auto-accept independent edits and to show structured conflicts when a person must decide.

Diff two strings line by line
-----------------------------

[](#diff-two-strings-line-by-line)

Feed two strings to `LineDiffer` and inspect the operations. Every `get_changes()` entry is a `[op, text]` pair.

```
