RFC 6902 JSON Patch: smart diffs, patching, audit and versioning.

Alto JSON Patch applies all six RFC 6902 operations and generates deterministic patches between PHP values.

<?php

use Alto\JsonPatch\JsonPatch;

$document = ['status' => 'draft'];
$patch = [
    ['op' => 'replace', 'path' => '/status', 'value' => 'published'],
];

$result = JsonPatch::apply($document, $patch);
echo $result['status'];

The result is published; the input remains unchanged. The package transforms in-memory values and JSON strings. Persistence, authorization, version storage, and conflict resolution remain application responsibilities.

Documentation

Patch operations

Start from one document, then inspect the PHP and its resulting JSON.

PHPInput
$document = [
    'status' => 'draft',
    'version' => 1,
    'owner' => 'alto',
];
JSONOriginal
  1. {
  2. "status": "draft",
  3. "version": 1,
  4. "owner": "alto"
  5. }
Original, 1 of 5