Skip to content

Commit 9423693

Browse files
committed
add sample usage
1 parent 9d4813c commit 9423693

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,31 @@ function bsdiff_diff(string $old_file, string $new_file, string $diff_file): voi
5454
function bsdiff_patch(string $old_file, string $new_file, string $diff_file): void {}
5555
```
5656

57+
Here is an example on how to use the extension:
58+
59+
```php
60+
<?php
61+
$old_file = '/path/to/the/old/file';
62+
$new_file = '/path/to/the/new/file';
63+
$diff_file = '/path/to/the/diff/file';
64+
65+
// To create the diff file.
66+
try {
67+
bsdiff_diff($old_file, $new_file, $diff_file);
68+
} catch (BsdiffException $e) {
69+
// Handle the exception.
70+
}
71+
72+
// To apply the diff file.
73+
$patched_file = '/path/to/the/patched/file';
74+
try {
75+
bsdiff_patch($old_file, $patched_file, $diff_file);
76+
} catch (BsdiffException $e) {
77+
// Handle the exception.
78+
}
79+
// File $patched_file will have exactly the same content as file $new_file.
80+
```
81+
5782
---
5883

5984
## License

0 commit comments

Comments
 (0)