stanislavk/gendiff

Second project on Hexlet

v1.1 2021-04-08 06:52 UTC

This package is auto-updated.

Last update: 2024-05-08 14:12:52 UTC


README

Command line app and PHP package installable with Composer to search for differences between two files

Actions Status

68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64653465613036663132613636356239666466302f6d61696e7461696e6162696c697479

Composer

composer require stanislavk/gendiff

Uses

<?php

use function Differ\Differ\genDiff;

$diff = genDiff($pathToFile1, $pathToFile2, $format = 'stylish');
print_r($diff);

Formats

'stylish' (default), 'plain' and 'json'.

file1.json:

{
  "host": "hexlet.io",
  "timeout": 50,
  "proxy": "123.234.53.22",
  "follow": false
}

file2.json:

{
  "timeout": 20,
  "verbose": true,
  "host": "hexlet.io"
}

Result

{
  - follow: false
    host: hexlet.io
  - proxy: 123.234.53.22
  - timeout: 50
  + timeout: 20
  + verbose: true
}

There is also a binary to run on the command line

Compare plane json files asciicast

Compare nested json files asciicast