Skip to content

Instantly share code, notes, and snippets.

@akovalyov
Created December 20, 2016 23:07
Show Gist options
  • Save akovalyov/5fc16a72382afcc3f384c82eb74e3d45 to your computer and use it in GitHub Desktop.
Save akovalyov/5fc16a72382afcc3f384c82eb74e3d45 to your computer and use it in GitHub Desktop.
Yaml for bash, php impl
# usage: cat app/config/parameters.yml | bin/yq '[parameters][database_host]'
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Yaml\Yaml;
$loader = require __DIR__ . '/../app/autoload.php';
$input = new ArgvInput();
$parsed = Yaml::parse(stream_get_contents(STDIN));
exit(PropertyAccess::createPropertyAccessor()->getValue($parsed, $input->getFirstArgument()) . PHP_EOL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment