### Install Dependencies Source: https://github.com/jfcherng/php-diff/blob/v6/example/README.md Installs the necessary project dependencies using Composer. This command should be run in the project's root directory. ```bash composer install ``` -------------------------------- ### PHP Diff Rendering Example (v6) Source: https://github.com/jfcherng/php-diff/blob/v6/UPGRADING/UPGRADING_v6.md Demonstrates the updated method for rendering differences using the Differ and Renderer classes in php-diff v6. It shows how to instantiate a Differ object and use a Renderer to get the diff result. ```php use Jfcherng\Diff\Differ; use Jfcherng\Diff\Factory\RendererFactory; $differ = new Differ(explode("\n", $old), explode("\n", $new), $diffOptions); $renderer = RendererFactory::make($rendererName, $rendererOptions); $result = $renderer->render($differ); ``` -------------------------------- ### Unified Diff Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt An example of the unified diff format output, showing context lines and changes with '+' for additions and '-' for deletions. ```diff --- Original +++ Modified @@ -1,3 +1,3 @@ Apple -Banana +Blueberry Cherry ``` -------------------------------- ### Run Web Demo Server Source: https://github.com/jfcherng/php-diff/blob/v6/example/README.md Starts the PHP development server for the web environment demo. Access the demo via http://localhost:12388/demo_web.php. ```bash composer run-script server ``` -------------------------------- ### Install php-diff using Composer Source: https://github.com/jfcherng/php-diff/blob/v6/README.md This snippet shows the Composer command to install the php-diff library. It is the standard method for adding PHP packages to a project. ```bash composer require jfcherng/php-diff ``` -------------------------------- ### HTML Diff Output Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-2-result.txt An example of the HTML output generated by the php-diff library, illustrating added and removed lines. ```html oranges grapefruits ``` -------------------------------- ### Text Comparison Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-2-new.txt Demonstrates a basic text comparison scenario, highlighting differences between two sets of lines. ```text ; test trailing OP_EQ EOL at EOF should be removed from the diff apples kiwis carrots grapefruits equal-line ``` -------------------------------- ### Diff Format Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-3-result.txt An example of the standard diff format used for representing changes between two versions of a file. ```diff --- a/original.txt +++ b/modified.txt @@ -1,4 +1,4 @@ ; test EOL at EOF A -B +C X ``` -------------------------------- ### HTML Diff Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt A basic HTML structure demonstrating how the HTML diff output might be displayed in a browser. ```html HTML Diff Example
        Line 1
        Line 2 - modified
        + Line 3
        - Line 4
    
``` -------------------------------- ### Document Version Comparison Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-1-result.txt This example demonstrates how the php-diff library can be used to compare different versions of a document. It shows how additions, deletions, and unchanged text are represented, providing a clear visual of the differences. ```text ; test case from https://en.wikipedia.org/wiki/Diff#Usage This is an important notice! It should therefore be located at the beginning of this document! This part of the document has stayed the same from version to compress the size of the changes. It is important to spell check this document. On the other hand, a misspelled word isn't the end of the world. this paragraph needs to be changed. Things can be added after it. This paragraph contains important new additions to this document. ``` -------------------------------- ### HTML JSON Renderer Example Source: https://github.com/jfcherng/php-diff/blob/v6/README.md Demonstrates the detailed HTML-style diff output for a 'rep' tag, showcasing changes between old and new content. This format is useful for detailed visual diffs. ```json [ [ { "tag": "rep", "old": { "offset": 0, "lines": ["<p>Hello World! Good-looking.</p>"] }, "new": { "offset": 0, "lines": ["<div>Hello World! Bad-tempered.</div>"] } }, { "tag": "eq", "old": { "offset": 1, "lines": ["~~~~~~~~~~~~~~~~~~~"] }, "new": { "offset": 1, "lines": ["~~~~~~~~~~~~~~~~~~~"] } }, { "tag": "ins", "old": { "offset": 2, "lines": [""] }, "new": { "offset": 2, "lines": ["Let's add a new line here."] } }, { "tag": "eq", "old": { "offset": 2, "lines": ["X"] }, "new": { "offset": 3, "lines": ["X"] } } ], [ { "tag": "eq", "old": { "offset": 6, "lines": ["N"] }, "new": { "offset": 7, "lines": ["N"] } }, { "tag": "rep", "old": { "offset": 7, "lines": ["Do you know in Chinese, \"金槍魚罐頭\" means tuna can."] }, "new": { "offset": 8, "lines": ["Do you know in Japanese, \"魚の缶詰\" means fish can."] } }, { "tag": "eq", "old": { "offset": 8, "lines": ["\t \tTab visualization test.", "G"] }, "new": { "offset": 9, "lines": ["\t \tTab visualization test.", "G"] } }, { "tag": "del", "old": { "offset": 10, "lines": ["// remember to delete this line"] }, "new": { "offset": 11, "lines": [""] } }, { "tag": "eq", "old": { "offset": 11, "lines": ["Say hello to my neighbors."] }, "new": { "offset": 11, "lines": ["Say hello to my neighbors."] } } ], [ { "tag": "eq", "old": { "offset": 14, "lines": ["B"] }, "new": { "offset": 14, "lines": ["B"] } }, { "tag": "rep", "old": { "offset": 15, "lines": ["Donec rutrum."] }, "new": { "offset": 15, "lines": ["Donec rutrum test.", "There is a new inserted line."] } }, { "tag": "eq", "old": { "offset": 16, "lines": ["C"] }, "new": { "offset": 17, "lines": ["C"] } }, { "tag": "rep", "old": { "offset": 17, "lines": ["Sed dictum lorem ipsum."] }, "new": { "offset": 18, "lines": ["Sed dolor lorem ipsum hendrerit."] } }, { "tag": "eq", "old": { "offset": 18, "lines": [""] }, "new": { "offset": 19, "lines": [""] } } ] ] ``` -------------------------------- ### Unified Diff Format Example Source: https://github.com/jfcherng/php-diff/blob/v6/README.md Demonstrates the Unified diff format, which is a common standard for representing differences between files. It shows added and removed lines with context. ```diff @@ -1,3 +1,4 @@ -

Hello World!

+
Hello World!
~~~~~~~~~~~~~~~~~~~ +Let's add a new line here. X @@ -7,6 +8,5 @@ N -Do you know in Chinese, "金槍魚罐頭" means tuna can. +Do you know in Japanese, "魚の缶詰" means fish can. This is just a useless line. G -// remember to delete this line Say hello to my neighbors. ``` -------------------------------- ### Wikipedia Diff Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-1-result.txt This snippet specifically addresses the example provided from Wikipedia regarding diff usage, showcasing how the library handles additions and deletions in a structured manner. ```diff --- Original +++ New @@ -1,4 +1,10 @@ ; test case from https://en.wikipedia.org/wiki/Diff#Usage +This is an important +notice! It should +therefore be located at +the beginning of this +document! + This part of the document has stayed the same from version to @@ -9,13 +15,8 @@ compress the size of the changes. -This paragraph contains -text that is outdated. -It will be deleted in the -near future. - It is important to spell -check this dokument. On +check this document. On the other hand, a misspelled word isn't the end of the world. @@ -23,3 +24,7 @@ this paragraph needs to be changed. Things can be added after it. + +This paragraph contains +important new additions +to this document. ``` -------------------------------- ### PHP Diff Calculation Examples Source: https://github.com/jfcherng/php-diff/blob/v6/README.md Demonstrates how to calculate differences between strings and files using the php-diff library. It covers both simplified one-line calculations and more detailed custom usage with specific renderer and differ options. ```php 3, // ignore case difference 'ignoreCase' => false, // ignore line ending difference 'ignoreLineEnding' => false, // ignore whitespace difference 'ignoreWhitespace' => false, // if the input sequence is too long, it will just gives up (especially for char-level diff) 'lengthLimit' => 2000, // if truthy, when inputs are identical, the whole inputs will be rendered in the output 'fullContextIfIdentical' => false, ]; // the renderer class options $rendererOptions = [ // how detailed the rendered HTML in-line diff is? (none, line, word, char) 'detailLevel' => 'line', // renderer language: eng, cht, chs, jpn, ... // or an array which has the same keys with a language file // check the "Custom Language" section in the readme for more advanced usage 'language' => 'eng', // show line numbers in HTML renderers 'lineNumbers' => true, // show a separator between different diff hunks in HTML renderers 'separateBlock' => true, // show the (table) header 'showHeader' => true, // the frontend HTML could use CSS "white-space: pre;" to visualize consecutive whitespaces // but if you want to visualize them in the backend with " ", you can set this to true 'spacesToNbsp' => false, // HTML renderer tab width (negative = do not convert into spaces) 'tabSize' => 4, // this option is currently only for the Combined renderer. // it determines whether a replace-type block should be merged or not // depending on the content changed ratio, which values between 0 and 1. 'mergeThreshold' => 0.8, // this option is currently only for the Unified and the Context renderers. // RendererConstant::CLI_COLOR_AUTO = colorize the output if possible (default) // RendererConstant::CLI_COLOR_ENABLE = force to colorize the output // RendererConstant::CLI_COLOR_DISABLE = force not to colorize the output 'cliColorization' => RendererConstant::CLI_COLOR_AUTO, // this option is currently only for the Json renderer. // internally, ops (tags) are all int type but this is not good for human reading. // set this to "true" to convert them into string form before outputting. 'outputTagAsString' => false, // this option is currently only for the Json renderer. // it controls how the output JSON is formatted. // see available options on https://www.php.net/manual/en/function.json-encode.php 'jsonEncodeFlags' => \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE, // this option is currently effective when the "detailLevel" is "word" // characters listed in this array can be used to make diff segments into a whole // for example, making "good-looking" into "good-looking" // this should bring better readability but set this to empty array if you do not want it 'wordGlues' => [' ', '-'], // change this value to a string as the returned diff if the two input strings are identical 'resultForIdenticals' => null, // extra HTML classes added to the DOM of the diff container 'wrapperClasses' => ['diff-wrapper'], ]; // one-line simply compare two files $result = DiffHelper::calculateFiles($oldFile, $newFile, $rendererName, $differOptions, $rendererOptions); // one-line simply compare two strings $result = DiffHelper::calculate($old, $new, $rendererName, $differOptions, $rendererOptions); // or even shorter if you are happy with default options $result = DiffHelper::calculate($old, $new, $rendererName); // custom usage $differ = new Differ(explode("\n", $old), explode("\n", $new), $differOptions); $renderer = RendererFactory::make($rendererName, $rendererOptions); // or your own renderer object $result = $renderer->render($differ); // use the JSON result to render in HTML $jsonResult = DiffHelper::calculate($old, $new, 'Json'); // may store the JSON result in your database $htmlRenderer = RendererFactory::make('Inline', $rendererOptions); $result = $htmlRenderer->renderArray(json_decode($jsonResult, true)); ``` -------------------------------- ### Context Diff Format Example Source: https://github.com/jfcherng/php-diff/blob/v6/README.md Illustrates the Context diff format, another standard for showing file differences. It includes lines of context around the changes, marked with '+' for additions and '-' for deletions. ```diff *************** *** 1,3 **** !

Hello World!

~~~~~~~~~~~~~~~~~~~ X --- 1,4 ---- !
Hello World!
~~~~~~~~~~~~~~~~~~~ + Let's add a new line here. X *************** *** 7,12 **** N ! Do you know in Chinese, "金槍魚罐頭" means tuna can. This is just a useless line. G - // remember to delete this line Say hello to my neighbors. --- 8,12 ---- N ! Do you know in Japanese, "魚の缶詰" means fish can. This is just a useless line. G Say hello to my neighbors. ``` -------------------------------- ### Text Diff Generation Example Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-2-result.txt Demonstrates how to generate a diff between two strings using the php-diff library. This is useful for tracking changes in text content. ```php render(); ?> ``` -------------------------------- ### php-diff v3 Constructor Changes Source: https://github.com/jfcherng/php-diff/blob/v6/UPGRADING/UPGRADING_v3.md In v3 of php-diff, the constructor for the `Jfcherng\Diff\Diff` class now requires the `$a` (old) and `$b` (new) parameters. These can be initialized as empty arrays if no initial diff operation is needed. ```php use Jfcherng\Diff\Diff; // Old constructor (prior to v3) // $diff = new Diff(); // New constructor (v3 and above) $oldString = "Hello World"; $newString = "Hi Universe"; $diff = new Diff($oldString, $newString); // Or with empty arrays if no initial diff is needed $diff = new Diff([], []); ``` -------------------------------- ### php-diff v3 Option Changes Source: https://github.com/jfcherng/php-diff/blob/v6/UPGRADING/UPGRADING_v3.md Version 3 of php-diff introduces changes to diff and template options. `charLevelDiff` and `separateBlock` are removed from `$diffOptions`. `detailLevel` (similar to `charLevelDiff`) and `separateBlock` are added to `$templateOptions`. ```php // Example of setting options (conceptual) // Before v3 $options = [ 'diff' => [ 'charLevelDiff' => true, 'separateBlock' => false ], 'template' => [ // ... other template options ] ]; // After v3 $options = [ 'diff' => [ // charLevelDiff and separateBlock removed from here ], 'template' => [ 'detailLevel' => 'char', // or 'line' 'separateBlock' => false ] ]; ``` -------------------------------- ### Get Default CSS for HTML Renderers Source: https://github.com/jfcherng/php-diff/blob/v6/README.md This PHP code demonstrates how to retrieve the default CSS content for HTML diff rendering. This CSS can be used to style the HTML output for better visualization. ```php echo \Jfcherng\Diff\DiffHelper::getStyleSheet(); ``` -------------------------------- ### php-diff v6.3.0 - Initial Release and Updates Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Version 6.3.0 of php-diff includes an initial release with dependency updates, example improvements, and code tidying. It also features updates for rendering HTML from JSON and adding tests for AbstractRenderer::renderArray. ```php /* * Version 6.3.0 - Initial release * - Update deps * - Update examples and README * - Variables renaming (example/demo.php) * - Add tests for \Jfcherng\Diff\Renderer\AbstractRenderer::renderArray * - Tidy codes * - Require jfcherng/php-sequence-matcher ^3.2 * - Let text renderers throw exception for renderArray() * - Ability to render HTML from JSON (#17) */ ``` -------------------------------- ### Text JSON Diff Output Example Source: https://github.com/jfcherng/php-diff/blob/v6/README.md This JSON structure represents a text difference, detailing changes line by line. Each change is categorized by a 'tag' (e.g., 'rep' for replace, 'ins' for insert, 'del' for delete, 'eq' for equal). It includes 'old' and 'new' objects, each containing an 'offset' and an array of 'lines' affected by the change. ```json [ [ { "tag": "rep", "old": { "offset": 0, "lines": ["

Hello World! Good-looking.

"] }, "new": { "offset": 0, "lines": ["
Hello World! Bad-tempered.
"] } }, { "tag": "eq", "old": { "offset": 1, "lines": ["~~~~~~~~~~~~~~~~~~~"] }, "new": { "offset": 1, "lines": ["~~~~~~~~~~~~~~~~~~~"] } }, { "tag": "ins", "old": { "offset": 2, "lines": [] }, "new": { "offset": 2, "lines": ["Let's add a new line here."] } }, { "tag": "eq", "old": { "offset": 2, "lines": ["X"] }, "new": { "offset": 3, "lines": ["X"] } } ], [ { "tag": "eq", "old": { "offset": 6, "lines": ["N"] }, "new": { "offset": 7, "lines": ["N"] } }, { "tag": "rep", "old": { "offset": 7, "lines": ["Do you know in Chinese, \"金槍魚罐頭\" means tuna can."] }, "new": { "offset": 8, "lines": ["Do you know in Japanese, \"魚の缶詰\" means fish can."] } }, { "tag": "eq", "old": { "offset": 8, "lines": ["\t \tTab visualization test.", "G"] }, "new": { "offset": 9, "lines": ["\t \tTab visualization test.", "G"] } }, { "tag": "del", "old": { "offset": 10, "lines": ["// remember to delete this line"] }, "new": { "offset": 11, "lines": [] } }, { "tag": "eq", "old": { "offset": 11, "lines": ["Say hello to my neighbors."] }, "new": { "offset": 11, "lines": ["Say hello to my neighbors."] } } ], [ { "tag": "eq", "old": { "offset": 14, "lines": ["B"] }, "new": { "offset": 14, "lines": ["B"] } }, { "tag": "rep", "old": { "offset": 15, "lines": ["Donec rutrum."] }, "new": { "offset": 15, "lines": ["Donec rutrum test.", "There is a new inserted line."] } }, { "tag": "eq", "old": { "offset": 16, "lines": ["C"] }, "new": { "offset": 17, "lines": ["C"] } }, { "tag": "rep", "old": { "offset": 17, "lines": ["Sed dictum lorem ipsum."] }, "new": { "offset": 18, "lines": ["Sed dolor lorem ipsum hendrerit."] } }, { "tag": "eq", "old": { "offset": 18, "lines": [""] }, "new": { "offset": 19, "lines": [""] } } ] ] ``` -------------------------------- ### php-diff Version 3.2.0 - None-Level and Line-Level Diff Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v3.md Initial release of version 3.2, introducing 'none-level' diff functionality and adding line-level diff examples. ```php /* * Version 3.2.0 - initial release * Add none-level diff * Add line-level diff to example.php * Unroll if-conditions for ReverseIterator::fromArray() */ ``` -------------------------------- ### Version 6.10.0 - Initial Release Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md This version marks the initial release of version 6.10.0, including updates to demo JavaScript and CSS URLs, documentation badges, and dependencies. It also introduces methods to get diff statistics. ```php feat: add methods to get diff statistics ``` -------------------------------- ### php-diff Version 4.1.7 - Various Fixes Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v4.md This snippet covers fixes in version 4.1.7 of php-diff, including updating example files, fixing AbstractHtml::expandTabs() with undeclared $tabSize, addressing issues in OP_EQ, improving expandTabs(), and code tidying. ```php 88ff257 Update example/old_file.txt and the new one. 32537b9 Fix AbstractHtml::expandTabs() $tabSize undeclared 37bd345 Fix problem caused by in OP_EQ, it still may be $old !== $new a821017 AbstractHtml::expandTabs() add argument: $onlyLeadingTabs bd00670 Code tidy 2031306 Update readme 0637909 Move upgrading guide from readme to other files 5e932e6 Separate CHANGELOG by major version ``` -------------------------------- ### php-diff Version 6.4.5 - CSS tweaks Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Includes various CSS adjustments for the SideBySide renderer, addressing issues with stripe display for nonexistent lines and improving overall appearance. Also updates documentation and example files. ```php /* * Version 6.4.5 - CSS tweaks * 2020-02-24 14:47 */ // SideBySide shows a stripe for nonexistent lines // Improve SideBySide CSS for nonexistent blocks // Make empty cells have height via CSS // Make coding thoughts more clear // Tidy Codes // Update SideBySide screenshot // Add a const for indicating showing all contexts // Add keywords to composer.json // Update example/README.md // Add more cases to example text sources // Update example/README.md ``` -------------------------------- ### Run CLI Demo Source: https://github.com/jfcherng/php-diff/blob/v6/example/README.md Executes the command-line interface demo script. ```php php demo_cli.php ``` -------------------------------- ### Applying a Diff Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-2-result.txt Demonstrates how to use the Diff class to generate a diff between two strings. It shows the basic instantiation and the `render` method. ```php render(); ?> ``` -------------------------------- ### php-diff Version 6.10 Features Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Details new features and fixes in version 6.10 of php-diff. Introduces methods to get diff statistics and updates dependencies. ```php feat: add methods to get diff statistics ``` ```php chore: bump "jfcherng/php-sequence-matcher" 3.2.8 ``` ```php chore: bump "jfcherng/php-sequence-matcher" 3.2.7 ``` -------------------------------- ### Diff with Options Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-3-result.txt Shows how to use the Differ class with specific options to control the output format, such as using HTML. ```php diff($oldString, $newString); echo $diff; ?> ``` -------------------------------- ### Diff File Content Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt Illustrates how to compare the content of two files and display the differences. This is useful for tracking changes in code or configuration files. ```php render(); ?> ``` -------------------------------- ### Unified Diff Format Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt Shows how to render the diff output in the unified diff format, commonly used by version control systems like Git. ```php render($diff); ?> ``` -------------------------------- ### Basic String Diff Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-3-result.txt Demonstrates a simple usage of the diffing functionality to compare two strings and show the changes. ```php diff($oldString, $newString); echo $diff; ?> ``` -------------------------------- ### Diff Output Format Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-2-result.txt Illustrates the typical output format of a text diff, showing added, removed, and unchanged lines. ```diff ; test trailing OP_EQ EOL at EOF should be removed from the diff apples -oranges kiwis carrots +grapefruits equal-line ``` -------------------------------- ### Diff Output Formats Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-1-result.txt Illustrates how to render the generated diff in different formats, such as HTML or a simple text-based diff. This is useful for displaying changes in various contexts. ```php HTML Diff:"; echo $diff->render(); // Render as unified diff format echo "

Unified Diff:

"; echo $diff->render('unified'); ?> ``` -------------------------------- ### php-diff Version 6.5.1 - Allow overriding SCSS variables Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Introduced the ability to override SCSS variables, providing more flexibility in styling. This version also includes code simplification for merging lines in the Combined renderer and updates to the example README. ```php /* * Version 6.5.1 - Allow overriding SCSS variables * 2020-02-29 02:30 */ // Allow overriding SCSS variables // Simplify codes for merging lines in Combined renderer // Update example readme // Prefer the new if we can only show either old or new ``` -------------------------------- ### Basic Diff Generation Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-1-result.txt Demonstrates the core functionality of generating a diff between two versions of a text document. This snippet shows how to use the library to compare content and produce a diff output. ```php render(); ?> ``` -------------------------------- ### Generate HTML Diff Output Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt Shows how to generate an HTML-formatted diff output, suitable for web display. It highlights added and removed lines. ```php render($diff); ?> ``` -------------------------------- ### php-diff Version 6.4.4 - Fix SideBySide wrong new line number Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Corrected an issue where the SideBySide renderer was displaying incorrect new line numbers. Also includes documentation updates and an example image for SideBySide without line numbers. ```php /* * Version 6.4.4 - Fix SideBySide wrong new line number * 2020-02-13 14:16 */ // Fix SideBySide wrong new line number // Fix documentation for outputTagAsString // Add example image for SideBySide without line numbers // Tidy codes ``` -------------------------------- ### Rendering Diff as HTML Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-2-result.txt Shows how to render the generated diff output in HTML format, suitable for web display. This utilizes the `renderHtml` method. ```php renderHtml(); ?> ``` -------------------------------- ### php-diff Version 5.0 Release Notes Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v5.md Details the initial release and subsequent fixes for version 5.0 of the php-diff library, including JSON renderer improvements, dependency updates, and code tidying. ```php * Version **5.0** - AFTERNOON * 2019-02-22 02:55 **5.0.2** fix Json renderer with empty changes * 6ca5b97 Fix Json renderer with empty changes * e512f2d Update CHANGELOG_v4.md * 2019-02-22 02:35 **5.0.1** fix dep * 7757363 squizlabs/php_codesniffer should be in require-dev * 6ac0c99 Update .rmt.yml * 2019-02-22 02:24 **5.0.0** initial release * 9f85206 Update .rmt.yml * 064a3b3 Add renderer option: outputTagAsString * 23c59f8 Update jfcherng/php-sequence-matcher ^3.0 * 1eb6bbb Update example/old_file.txt and the new one. * b9f2f7b Fix AbstractHtml::expandTabs() $tabSize undeclared * 469abb7 Fix problem caused by in OP_EQ, it still may be $old !== $new * 82ed9ca AbstractHtml::expandTabs() add argument: $onlyLeadingTabs * dd6d8dc Code tidy * 4750267 Move upgrading guide from readme to other files * 12b6024 Separate CHANGELOG by major version * ebbb509 Update readme * ef735c9 Code tidy * 4518927 Uniform more "from, to" into "old, new" * 079a5ec Update readme * dbcf0b8 Update readme * b84bef5 Remove deprecated APIs * 5330cd2 Uniform the term "base, changed" into "old, new" ``` -------------------------------- ### php-diff Version 5.2 Release Notes Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v5.md Details the changes and fixes in version 5.2 of the php-diff library, including dependency updates, Travis CI configuration for PHP 7.4, and readme improvements. ```php ## VERSION 5 AFTERNOON * Version **5.2** - clean up * 2019-05-15 00:17 **5.2.2** Final Release for v5 * 2bd27d4 Update deps * fa189fa Update deps * 6b30019 Update deps * abc0d8a $ composer fix * 7cb5a75 Update deps * 70f66a2 Update .travis.yml for 7.4snapshot * e7e1839 Update deps * 1cee802 Update readme * 756970a Add .editorconfig * e6350bc Change screenshot size * 55748a5 Update deps * 03b0c55 Freeze documentation assets for v5 * bd61843 Freeze documentation assets for v4 * 2019-03-04 23:03 **5.2.1** tiny fixes * ed2bf46 Fix Diff::getOldNewComparison() should use finalize() * ecde729 Fix codacy's complaint * 5efa215 Revise the Language class (no BC break) * 3b369f8 Type-safe for Language::getTranslationsByLanguage() * d442360 Remove unneccesary phan error suppression * 8dffcb3 Fix readme badge * 2019-03-04 04:05 **5.2.0** initial release * ef500d0 Deprecate AbstractRenderer::getIdenticalResult() * 88648e3 nits * 0861774 $ php-cs-fix fix * bfbdd3d [php-cs-fixer] Add new rules: @PhpCsFixer, @PhpCsFixer:risky * dfeb1b8 Improve JSON decoding in Language::getTranslationsByLanguage() * 414eb29 Release of new version 4.2.3 * 9d51c33 Make Language::getTranslationsByLanguage() safer * 8acb535 Fix a typo * 2b620b3 Use native class name * b76301a Fix a typo in readme * 8745678 Release of new version 4.2.2 * 6117ab9 Adapt some non-breaking changes from the master branch * 8b06983 nits * 5659dc4 Update deps * cfb2652 Move CHANGELOG and UPGRADING * 28216ed Release of new version 4.2.1 ``` -------------------------------- ### php-diff Version 2.1.17 Release Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v2.md Code tidying, dependency updates, and exception handling improvements in version 2.1.17 of php-diff. Includes adding FileNotFoundException and aliasing bg.php to bul.php. ```php 9297443 nits 9251d8b Add FileNotFoundException 7684942 Update deps 04590f1 Update README e0e11e19 Alias bg.php to bul.php e186ff7 micro code tweak 28a423f Fix some typos 96c679c Update deps ``` -------------------------------- ### php-diff Version 4.0.0 - Strip SequenceMatcher Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v4.md This snippet details the initial release of version 4.0.0 for php-diff, which involves stripping out SequenceMatcher as an external package. It also includes demo improvements, CI fixes, test updates, and native exception usage. ```php fac4dae nits b6fa08d Strip out SequenceMatcher as an external package 2349bb2 Demo uses "font-family: monospace" ed3f47c Temporary fix for CI 538f270 Update tests 11cf372 Fix typos d56ad7e Use native exceptions 67351d1 Update deps 8b14dae Add "final" to classes non-inherited ee6e5a3 Add UTF-8-ready demo bf686a2 Prepare for being a new package 04fb079 nits ``` -------------------------------- ### Generate Diff Output Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Context-5-result.txt Demonstrates how to generate a diff output between two strings using the Diff class. This is useful for identifying changes. ```php render(); ?> ``` -------------------------------- ### php-diff Version 6.3.1 - Remove dep: nicmart/string-template Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v6.md Removed the dependency on `nicmart/string-template` and updated development requirements and the README file. ```php /* * Version 6.3.1 - Remove dep: nicmart/string-template * 2020-01-12 01:08 */ // Update dev require // Update readme [skip ci] ``` -------------------------------- ### Combined Renderer Configuration Source: https://github.com/jfcherng/php-diff/blob/v6/README.md Configures the Combined renderer for php-diff, specifying the detail level for rendering differences. This renderer is suitable for articles and does not display line numbers. ```php 'word'];?> ``` -------------------------------- ### php-diff Version 4.2.0 - Initial Release Source: https://github.com/jfcherng/php-diff/blob/v6/CHANGELOG/CHANGELOG_v4.md This snippet details the initial release of version 4.2.0 for php-diff. Key changes include code formatting with php-cs-fixer, adding DiffHelper::getProjectDirectory(), updating renderer info, rewriting template methods, and dependency updates for phpunit. ```php 43566f1 php-cs-fixer be70f5e Add DiffHelper::getProjectDirectory() 4937417 Add INFO['type'] for renderers 3ef51f6 Rewrite DiffHelper::getTemplatesInfo() and DiffHelper::getStyleSheet() 5e0f0da Add DiffHelper::getStyleSheet() c7e5312 require-dev at least phpunit/phpunit 7.5 01d52fd Add DiffHelper::calculateFiles() 4601400 No need to clear cached value if $old/$new does not change d690144 Code tidy ``` -------------------------------- ### Line-based Diff Source: https://github.com/jfcherng/php-diff/blob/v6/tests/data/renderer_outputs/Unified-3-result.txt Illustrates how to perform a diff operation specifically on lines of text, useful for comparing files. ```php diff($oldLines, $newLines); print_r($diff); ?> ```