Skip to content

Instantly share code, notes, and snippets.

@ostrolucky
Last active January 3, 2018 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ostrolucky/775b36fd524a07bc2124d76cc9d2b224 to your computer and use it in GitHub Desktop.
Save ostrolucky/775b36fd524a07bc2124d76cc9d2b224 to your computer and use it in GitHub Desktop.
Example usage Symfony Yaml custom tags
<?php
require 'vendor/autoload.php';
$parsed = \Symfony\Component\Yaml\Yaml::parse(<<<YAML
test:
a: !b64baby stuff
b: foo
YAML
, \Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS);
array_walk_recursive($parsed, function(&$value) {
if ($value instanceof \Symfony\Component\Yaml\Tag\TaggedValue && $value->getTag() === 'b64baby') {
$value = base64_encode($value->getValue());
}
});
print_r($parsed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment