occulo / gendiff
A PHP-based diff generator for files
v1.0.0
2026-03-11 16:31 UTC
Requires
- php: >=8.3
- docopt/docopt: ^1.0
- funct/funct: ^1.6
- symfony/yaml: ^7.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- squizlabs/php_codesniffer: ^4.0
README
Description
Gendiff is a CLI tool and library for generating differences between two configuration files. Supports multiple output formats: stylish, plain, and JSON.
Prerequisites
- Linux, MacOS, WSL
- PHP >=8.3
- Composer >=2.0
- Git
- Make
Installation
Composer (recommended)
If you use Composer, you can install the package locally with the following command:
composer require occulo/gendiff
Or globally:
composer global require occulo/gendiff
Source
If you wish to install from source, run:
git clone https://github.com/occulo/gendiff.git
cd gendiff
make install
This will clone the repository to your machine and install all required Composer dependencies.
Supported Formats
Gendiff can compare configuration files in the following formats:
- JSON (
.json) - YAML (
.yaml,.yml)
Usage
gendiff (-h|--help) gendiff (-v|--version) gendiff [--format <fmt>] <firstFile> <secondFile>
Demo
Input files
file1.json
{
"key1": "value1",
"key2": true,
"key3": 123
}
file2.json
{
"key1": "value1",
"key2": false,
"key4": "new"
}
Stylish format
gendiff --format stylish file1.json file2.json
{
key1: value1
- key2: true
+ key2: false
- key3: 123
+ key4: new
}
Plain format
gendiff --format plain file1.json file2.json
Property 'key2' was updated. From true to false Property 'key3' was removed Property 'key4' was added with value: 'new'
JSON format
gendiff --format json file1.json file2.json
{
"key1": {
"status": "unchanged",
"value": "value1"
},
"key2": {
"status": "changed",
"value": {
"old": true,
"new": false
}
},
"key3": {
"status": "removed",
"value": 123
},
"key4": {
"status": "added",
"value": "new"
}
}