Skip to content

Commit 6da9215

Browse files
committed
Update example readme
Signed-off-by: Jack Cherng <[email protected]>
1 parent a0b906b commit 6da9215

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

example/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ In the parent folder (i.e., this project's root directory):
55
1. Install dependencies with `composer upgrade`.
66
1. Start PHP development server with `composer run-script server`.
77
1. Visit `http://localhost:12388/demo.php` with your web browser.
8+
1. Change `old_file.txt`, `new_file.txt` and refresh the web page to play around.

example/demo.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<body>
1818
<?php
1919

20-
// include two sample files for comparison
21-
$oldFilePath = __DIR__ . '/old_file.txt';
22-
$newFilePath = __DIR__ . '/new_file.txt';
23-
$oldFile = \file_get_contents($oldFilePath);
24-
$newFile = \file_get_contents($newFilePath);
20+
// the two sample files for comparison
21+
$oldFile = __DIR__ . '/old_file.txt';
22+
$newFile = __DIR__ . '/new_file.txt';
23+
$oldString = \file_get_contents($oldFile);
24+
$newString = \file_get_contents($newFile);
2525

2626
// options for Diff class
2727
$diffOptions = [
@@ -67,8 +67,8 @@
6767

6868
// demo the no-inline-detail diff
6969
$inlineResult = DiffHelper::calculate(
70-
$oldFile,
71-
$newFile,
70+
$oldString,
71+
$newString,
7272
'Inline',
7373
$diffOptions,
7474
['detailLevel' => 'none'] + $rendererOptions
@@ -83,8 +83,8 @@
8383

8484
// demo the word-level diff
8585
$inlineResult = DiffHelper::calculate(
86-
$oldFile,
87-
$newFile,
86+
$oldString,
87+
$newString,
8888
'Inline',
8989
$diffOptions,
9090
['detailLevel' => 'line'] + $rendererOptions
@@ -99,8 +99,8 @@
9999

100100
// demo the word-level diff
101101
$inlineResult = DiffHelper::calculate(
102-
$oldFile,
103-
$newFile,
102+
$oldString,
103+
$newString,
104104
'Inline',
105105
$diffOptions,
106106
['detailLevel' => 'word'] + $rendererOptions
@@ -115,8 +115,8 @@
115115

116116
// demo the character-level diff
117117
$inlineResult = DiffHelper::calculate(
118-
$oldFile,
119-
$newFile,
118+
$oldString,
119+
$newString,
120120
'Inline',
121121
$diffOptions,
122122
['detailLevel' => 'char'] + $rendererOptions
@@ -131,8 +131,8 @@
131131

132132
// generate a side by side diff
133133
$sideBySideResult = DiffHelper::calculateFiles(
134-
$oldFilePath,
135-
$newFilePath,
134+
$oldFile,
135+
$newFile,
136136
'SideBySide',
137137
$diffOptions,
138138
$rendererOptions
@@ -147,8 +147,8 @@
147147

148148
// generate an inline diff
149149
$inlineResult = DiffHelper::calculateFiles(
150-
$oldFilePath,
151-
$newFilePath,
150+
$oldFile,
151+
$newFile,
152152
'Inline',
153153
$diffOptions,
154154
$rendererOptions
@@ -163,8 +163,8 @@
163163

164164
// generate a combined diff
165165
$sideBySideResult = DiffHelper::calculateFiles(
166-
$oldFilePath,
167-
$newFilePath,
166+
$oldFile,
167+
$newFile,
168168
'Combined',
169169
$diffOptions,
170170
$rendererOptions
@@ -179,8 +179,8 @@
179179

180180
// generate a unified diff
181181
$unifiedResult = DiffHelper::calculateFiles(
182-
$oldFilePath,
183-
$newFilePath,
182+
$oldFile,
183+
$newFile,
184184
'Unified',
185185
$diffOptions,
186186
$rendererOptions
@@ -195,8 +195,8 @@
195195

196196
// generate a context diff
197197
$contextResult = DiffHelper::calculateFiles(
198-
$oldFilePath,
199-
$newFilePath,
198+
$oldFile,
199+
$newFile,
200200
'Context',
201201
$diffOptions,
202202
$rendererOptions
@@ -211,8 +211,8 @@
211211

212212
// generate a JSON diff
213213
$jsonResult = DiffHelper::calculateFiles(
214-
$oldFilePath,
215-
$newFilePath,
214+
$oldFile,
215+
$newFile,
216216
'Json',
217217
$diffOptions,
218218
['outputTagAsString' => true] + $rendererOptions

0 commit comments

Comments
 (0)