Download the PHP package bircher/php-merge without Composer
On this page you can find all versions of the php package bircher/php-merge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bircher/php-merge
More information about bircher/php-merge
Files in bircher/php-merge
Package php-merge
Short Description A PHP merge utility using the Diff php library or the command line git.
License MIT
Homepage https://github.com/bircher/php-merge
Informations about the package php-merge
php-merge
Introduction
When working with revisions of text one sometimes faces the problem that there are several revisions based off the same original text. Rather than choosing one and discarding the other we want to merge the two revisions.
Git does that already wonderfully. In a php application we want a simple tool
that does the same. There is the xdiff PECL extension
which has the xdiff_string_merge3
function. But xdiff_string_merge3
does not behave the same way as git and
xdiff may not be available on your system.
PhpMerge is a small library that solves this problem. There are two classes:
\PhpMerge\PhpMerge
and \PhpMerge\GitMerge
that implement the
\PhpMerge\PhpMergeInterface
which has just a merge
method.
PhpMerge
uses SebastianBergmann\Diff\Differ
to get the differences between
the different versions and calculates the merged text from it.
GitMerge
uses Symplify\GitWrapper\GitWrapper
, writes the text to a temporary file
and uses the command line git to merge the text.
Usage
Simple example:
With merge conflicts:
Using the command line git to perform the merge:
Installation
PhpMerge can be installed with Composer by adding the library as a dependency to your composer.json file.
To use the command line git with GitMerge
:
Please refer to Composer's documentation for installation and usage instructions.
Difference to ~3.0
In the ~4.0 version we switch from cpliakas/git-wrapper
to symplify/git-wrapper
since the former is deprecated.
This update means that there is no change when only using PhpMerge\PhpMerge
.