Skip to content

Instantly share code, notes, and snippets.

@freephile
Created February 22, 2024 05:01
Show Gist options
  • Save freephile/b6e06e7f3e6a1daa24116e69886ea2d9 to your computer and use it in GitHub Desktop.
Save freephile/b6e06e7f3e6a1daa24116e69886ea2d9 to your computer and use it in GitHub Desktop.
Compare (diff) two yaml files
<?php
/**
* This script is a CLI tool for quickly comparing an online yaml file with a local file
*
* @param string $url - the URL value for the location of an online YAML file
* @param string $file - the full path of a local YAML file e.g. MezaCoreExtensions.yml
*
* You could easily just do the same thing with diff, wdiff, sdiff
* Or, using a GUI with Kompare, Meld, DiffMerge, diffuse, KDiff3
*/
// permalink for the GRC-ATF branch on 2024-01-16
$url="https://github.com/nasa/meza/blob/95aaf6a61cf2a1b82bccf7a40935af7475a102c6/config/MezaCoreExtensions.yml";
// local file
$file="/opt/meza/config/MezaCoreExtensions.yml";
$meza135extensionList = yaml_parse_url( $url );
$meza139extensionList = yaml_parse_file( $file );
$diff = array_diff( $meza135extensionList, $meza139extensionList );
var_dump($diff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment