2017 © Pedro Peláez
 

library php-diff

image

sokil/php-diff

  • Tuesday, March 20, 2018
  • by sokil
  • Repository
  • 2 Watchers
  • 2 Stars
  • 27 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

php-diff

Highlight diffs provided by Sebastian Bergmann diff, (*1)

Build Status Coverage Status Total Downloads, (*2)

Installation

composer.phar require sokil/php-diff

Useage

<?php

use Sokil\Diff\Change;
use Sokil\Diff\Renderer;

$diffRenderer = new Renderer();
$actualDiff = $diffRenderer->render(new Change(
    implode(PHP_EOL, ['line1', 'line2', 'line3']),
    implode(PHP_EOL, ['line1', 'line2changed', 'line3'])
));

Format of diff output

Format of diff tags may be configured. By default renders only two tags: <ins> and <del>. To highlight output, use predefined format:, (*3)

<?php
$renderer = new Renderer([
    'format' => Renderer::FORMAT_COLOUR
]);

This will produce following HTML:, (*4)

line1
<del style="background: #ffe7e7;">line2</del>
<ins style="background: #ddfade;">line2changed</ins>
line3

To fully customize style, use next syntax (this format has alias Renderer::FORMAT_COLOUR):, (*5)

<?php
$renderer = new Renderer([
    'format' => [
        'insert' => [
            'tag' => 'ins',
            'attributes' => 'style="background: #ddfade;"',
        ],
        'delete' => [
            'tag' => 'del',
            'attributes' => 'style="background: #ffe7e7;"',
        ]
    ]
]);

// this is same to
$renderer = new Renderer([
    'format' => Renderer::FORMAT_COLOUR
]);

Default format Renderer::FORMAT_DEFAULT has following notation:, (*6)

<?php
$renderer = new Renderer([
    'insert' => [
        'tag' => 'ins',
    ],
    'delete' => [
        'tag' => 'del',
    ]
]);

// this is same to
$renderer = new Renderer([
    'format' => Renderer::FORMAT_DEFAULT
]);

The Versions

20/03 2018

dev-sokil-patch-2

dev-sokil-patch-2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

20/03 2018

dev-sokil-patch-1

dev-sokil-patch-1

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

06/03 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

30/08 2016

0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

28/08 2016

0.3

0.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

09/08 2016

0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

09/08 2016

0.2

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmytro Sokil

17/05 2016

0.1

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Dmytro Sokil