stanislavk/gendiff

Second project on Hexlet

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

This package is auto-updated.

Last update: 2025-06-08 16:39:40 UTC


README

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

Actions Status

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