stanislavk/gendiff

Hexlet 的第二个项目

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

This package is auto-updated.

Last update: 2024-09-08 15:11:13 UTC


README

命令行应用程序和PHP包,可以通过Composer安装,用于在两个文件之间查找差异

Actions Status

Composer

composer require stanislavk/gendiff

使用

<?php

use function Differ\Differ\genDiff;

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

格式

'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"
}

结果

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

还有可以在命令行上运行的二进制文件

比较平面json文件 asciicast

比较嵌套json文件 asciicast