Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Last active August 29, 2015 14:16
Show Gist options
  • Save gonzaloserrano/f7aaa84f69dbb80d701e to your computer and use it in GitHub Desktop.
Save gonzaloserrano/f7aaa84f69dbb80d701e to your computer and use it in GitHub Desktop.
<?php
require_once 'vendor/autoload.php';
$localTable = [
["fd", "df"],
["fd", "fd"],
[null, "fd"],
["fd", null],
];
$remoteTable = [
["A", "new_column_2"],
[null, null],
["fd", "df"],
["fd", "fd"],
];
$localTableView = new \coopy_PhpTableView($localTable);
$remoteTableView = new \coopy_PhpTableView($remoteTable);
$compareView = \coopy_Coopy::compareTables($localTableView, $remoteTableView);
// compute aligment
$alignment = $compareView->align();
// produce the diff
$tableDiffData = [];
$tableDiffView = new \coopy_PhpTableView($tableDiffData);
$flags = new \coopy_CompareFlags();
$flags->always_show_order = true;
$flags->never_show_order = false;
$highlighter = new \coopy_TableDiff($alignment, $flags);
$highlighter->hilite($tableDiffView);
$htmlDiffRender = new \coopy_DiffRender();
$htmlDiffRender->usePrettyArrows(false);
$htmlDiffRender->render($tableDiffView);
echo $htmlDiffRender->html();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment