Download the PHP package nochso/diff without Composer
On this page you can find all versions of the php package nochso/diff. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package diff
Short Description Diff implementation
License BSD-3-Clause
Homepage https://github.com/nochso/diff
Informations about the package diff
nochso/diff
Namespace:
\nochso\Diff
Diff implementation for PHP with support for text, HTML and console output out of the box.
This library is a fork of sebastian/diff: While the original diff implementation has not notably changed, new features were added:
- Configurable limit for lines of context around the modified lines
- Plain PHP templates for displaying diffs in:
- Plain text
- Colored POSIX console output
- HTML
- Github flavoured Markdown
- Modify existing templates or create your own
- Line numbering based on the "before" string
-
Upstream
formatter for maintaining compatibility withsebastian/diff
— and to keep the original tests around -
- nochso/diff
- Installation
- Usage
Installation
Usage
Start with creating a Diff
object by passing two strings to Diff::create()
:
The Diff object contains a list of DiffLine
objects, consisting of text, a
line number and the type of diff operation.
Most of the time you'll want to display the diff somewhere. You can pass a Diff
instance to anything that implements the Formatter
interface:
Output:
How about two lines of context and Github flavoured Markdown?
As you can see, when creating a Diff you can pass a ContextDiff object to change the default behaviour.