1. Go to this page and download the library: Download grasmash/yaml-expander 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/ */
grasmash / yaml-expander example snippets
// Set an environmental variable, accessible via ${env.TZ}.
putenv("TZ=ES");
// Parse a yaml string directly, expanding internal property references.
$yaml_string = file_get_contents("dune.yml");
$expanded = \Grasmash\YamlExpander\YamlExpander::parse($yaml_string);
print_r($expanded);
// Parse an array, expanding internal property references.
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
$expanded = \Grasmash\YamlExpander\YamlExpander::expandArrayProperties($array);
print_r($expanded);
// Parse an array, expanding references using both internal and supplementary values.
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
$reference_properties = ['book' => ['publication-year' => 1965]];
$expanded = \Grasmash\YamlExpander\YamlExpander::expandArrayProperties($array, $reference_properties);
print_r($expanded);