@@ -27,19 +27,27 @@ Or clone it locally via GIT, or download any of the
27
27
### Comparing strings
28
28
29
29
``` php
30
+ use Mistralys\Diff\Diff;
31
+
30
32
$diff = Diff::compareStrings('String 1', 'String 2');
31
33
```
32
34
33
35
### Comparing files
34
36
35
37
``` php
38
+ use Mistralys\Diff\Diff;
39
+
36
40
$diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
37
41
```
38
42
39
43
Once the diff instance has been created, choose any of the ` toXXX `
40
44
methods to retrieve the diff in your preferred format.
41
45
42
46
``` php
47
+ use Mistralys\Diff\Diff;
48
+
49
+ $diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
50
+
43
51
$string = $diff->toString();
44
52
$html = $diff->toHTML();
45
53
$table = $diff->toHTMLTable();
@@ -52,6 +60,10 @@ By default, the comparison will be made per line. It can be changed
52
60
to be done on a per-character basis:
53
61
54
62
``` php
63
+ use Mistralys\Diff\Diff;
64
+
65
+ $diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
66
+
55
67
$diff->setCompareCharacters(true);
56
68
```
57
69
@@ -62,12 +74,19 @@ changes with the integrated CSS styles. To insert these, use the
62
74
` Styler ` class: it offers several ways to access the CSS.
63
75
64
76
``` php
77
+ use Mistralys\Diff\Diff;
78
+
79
+ $diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
65
80
$styler = Diff::createStyler();
66
81
```
67
82
68
83
From here, use any of the styler's methods according to your project's needs.
69
84
70
85
``` php
86
+ use Mistralys\Diff\Diff;
87
+
88
+ $styler = Diff::createStyler();
89
+
71
90
$css = $styler->getCSS(); // get the raw CSS styles
72
91
$tag = $styler->getStyleTag(); // CSS styles with a <style > tag
73
92
$path = $styler- > getStylesheetPath(); // absolute path to the file
@@ -77,6 +96,8 @@ $url = $styler->getStylesheetURL('/vendor'); // URL to the file, given the vendo
77
96
For example, to show a highlighted diff with inline styles:
78
97
79
98
```php
99
+ use Mistralys\D iff\D iff;
100
+
80
101
$diff = Diff::compareStrings('String 1', 'String 2');
81
102
82
103
echo Diff::createStyler()-> getStyleTag();
0 commit comments