9
9
A comprehensive library for generating differences between
10
10
two hashable objects (strings or arrays). Generated differences can be
11
11
rendered in all of the standard formats including:
12
- * Unified
13
- * Context
14
- * Inline HTML
15
- * Side by Side HTML
16
- * Unified HTML
12
+ * Unified
13
+ * Context
14
+ * Inline HTML
15
+ * Side by Side HTML
16
+ * Unified HTML
17
17
18
18
The logic behind the core of the diff engine (ie, the sequence matcher)
19
19
is primarily based on the Python difflib package. The reason for doing
@@ -22,38 +22,40 @@ so is primarily because of its high degree of accuracy.
22
22
23
23
## Install
24
24
25
- ```
25
+ ``` shell
26
26
composer require jblond/php-diff
27
27
```
28
28
29
29
## Example Use
30
30
31
31
``` PHP
32
32
<?php
33
- // installed via composer
33
+ // Installed via composer...
34
34
require 'vendor/autoload.php';
35
-
36
- // or installed manual
35
+ // ...or installed manually.
37
36
require dirname(__FILE__).'/../lib/Autoloader.php';
37
+
38
38
new \jblond\Autoloader();
39
39
40
40
$a = file_get_contents(dirname(__FILE__).'/a.txt');
41
41
$b = file_get_contents(dirname(__FILE__).'/b.txt');
42
- // Options for generating the diff
42
+
43
+ // Options for generating the diff.
43
44
$options = [
44
45
//'ignoreWhitespace' => true,
45
46
//'ignoreCase' => true,
46
47
];
47
- // Initialize the diff class
48
+
49
+ // Initialize the diff class.
48
50
$diff = new \jblond\Diff($a, $b, $options);
49
51
50
- //choose renderer
52
+ // Choose Renderer.
51
53
$renderer = new \jblond\Diff\Renderer\Html\SideBySide([
52
54
'title_a' => 'Custom title for OLD version',
53
55
'title_b' => 'Custom title for NEW version',
54
56
]);
55
57
56
- //show it
58
+ // Show it.
57
59
echo $diff->Render($renderer);
58
60
```
59
61
@@ -67,8 +69,8 @@ example.php.
67
69
68
70
## Requirements
69
71
70
- - PHP 7.2 or greater
71
- - PHP Multibyte String
72
+ * PHP 7.2 or greater
73
+ * PHP Multibyte String
72
74
73
75
## Merge files using jQuery
74
76
@@ -77,25 +79,25 @@ files. Have a look at [jQuery-Merge-for-php-diff](https://github.com/Xiphe/jQuer
77
79
78
80
## Todo
79
81
80
- * Ability to ignore blank line changes
81
- * 3 way diff support
82
+ * Ability to ignore blank line changes
83
+ * 3 way diff support
82
84
83
- ## Contributors
85
+ ## Contributors
84
86
85
87
Contributors since I forked the repo.
86
88
87
- - maxxer
88
- - Creris
89
- - jfcherng
90
- - DigiLive
89
+ * maxxer
90
+ * Creris
91
+ * jfcherng
92
+ * DigiLive
91
93
92
94
### License (BSD License)
93
95
94
96
see [ License] ( LICENSE )
95
97
96
- ## tests
98
+ ## Tests
97
99
98
- ``` BASH
100
+ ``` shell
99
101
composer run-script phpunit
100
102
composer run-script php_src
101
103
composer run-script php_test
0 commit comments