foreachq/gendiff

Structure differences finder

v1.1 2022-03-11 14:18 UTC

This package is auto-updated.

Last update: 2024-04-11 19:03:22 UTC


README

PHP CI 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61313736636330613764356435636431616166332f6d61696e7461696e6162696c697479 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61313736636330613764356435636431616166332f746573745f636f766572616765

Gendiff

«Gendiff» — a program that finds the difference between two data structures.

Description

Can be used as a separate CLI application or imported as a php package.

Program gets 2 paths and output format as input and returns structures differences in user defined format.

Utility features:

  • Recursive processing;
  • Support for different input formats: yaml and json;
  • Report generation in the form of plain text, "stylish" and json.

Requirements

  • php 7.4
  • composer 2.*

Installation

Php package

composer require foreachq/gendiff

Cli application

  • Download package
composer create-project foreachq/gendiff
  • Install dependencies
make install

Usage

CLI

# format plain
$ ./gendiff --format plain path/to/file.yml another/path/file.json

Property 'common.follow' was added with value: false
Property 'group1.baz' was updated. From 'bas' to 'bars'
Property 'group2' was removed

# format by default (stylish)
$ ./gendiff filepath1.json filepath2.json

{
  + follow: false
    setting1: Value 1
  - setting2: 200
  - setting3: true
  + setting3: {
        key: value
    }
  + setting4: blah blah
  + setting5: {
        key5: value5
    }
}

$ ./gendiff -h # for help

Php package

use function Differ\Differ\genDiff;

// formats: stylish (default), plain, json
$diff = genDiff($pathToFile1, $pathToFile2, $format);
print_r($diff);

Asciinemas of usage