PHP code example of hgato / php-crud-comparator

1. Go to this page and download the library: Download hgato/php-crud-comparator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hgato / php-crud-comparator example snippets


class TestObject
{
  public $id;
  public $key;
  public $name;
  public $description;
}

$oldArray = [/* Some instances of TestObject*/];
$newArray = [/* Other instances of TestObject*/];

$comparator = new ObjectComparator();
$comparator->compare(
    $oldArray,
    $newArray,
    ['id', 'key'],
    ['name', 'description']
);

$create = $comparator->getCreate();
$update = $comparator->getUpdate();
$delete = $comparator->getDelete();