{"id":14985625,"url":"https://github.com/grasmash/yaml-expander","last_synced_at":"2025-04-12T14:58:49.665Z","repository":{"id":15796891,"uuid":"78783041","full_name":"grasmash/yaml-expander","owner":"grasmash","description":"Expands internal property references in a yaml file.","archived":false,"fork":false,"pushed_at":"2024-05-05T19:19:21.000Z","size":205,"stargazers_count":152,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T14:58:43.576Z","etag":null,"topics":["php","yaml","yml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grasmash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-12T20:14:23.000Z","updated_at":"2024-10-31T19:25:20.000Z","dependencies_parsed_at":"2024-05-05T20:28:47.810Z","dependency_job_id":"b43cfb19-5e9c-4034-8e93-eef0301382bb","html_url":"https://github.com/grasmash/yaml-expander","commit_stats":{"total_commits":68,"total_committers":7,"mean_commits":9.714285714285714,"dds":"0.38235294117647056","last_synced_commit":"f6dd6be2a899316528e201c91fc317b16794b1c0"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fyaml-expander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fyaml-expander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fyaml-expander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fyaml-expander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grasmash","download_url":"https://codeload.github.com/grasmash/yaml-expander/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586249,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","yaml","yml"],"created_at":"2024-09-24T14:11:23.107Z","updated_at":"2025-04-12T14:58:49.643Z","avatar_url":"https://github.com/grasmash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/grasmash/yaml-expander/actions/workflows/php.yml/badge.svg)](https://github.com/grasmash/yaml-expander/actions/workflows/php.yml) [![Packagist](https://img.shields.io/packagist/v/grasmash/yaml-expander.svg)](https://packagist.org/packages/grasmash/yaml-expander)\n[![Total Downloads](https://poser.pugx.org/grasmash/yaml-expander/downloads)](https://packagist.org/packages/grasmash/yaml-expander) [![Coverage Status](https://coveralls.io/repos/github/grasmash/yaml-expander/badge.svg?branch=master)](https://coveralls.io/github/grasmash/yaml-expander?branch=master)\n\nThis tool expands property references in YAML files.\n\n### Installation\n\n    composer require grasmash/yaml-expander\n\n### Example usage:\n\nExample dune.yml:\n\n```yaml\ntype: book\nbook:\n  title: Dune\n  author: Frank Herbert\n  copyright: ${book.author} 1965\n  protaganist: ${characters.0.name}\n  media:\n    - hardcover\ncharacters:\n  - name: Paul Atreides\n    occupation: Kwisatz Haderach\n    aliases:\n      - Usul\n      - Muad'Dib\n      - The Preacher\n  - name: Duncan Idaho\n    occupation: Swordmaster\nsummary: ${book.title} by ${book.author}\nproduct-name: ${${type}.title}\ntimezone: ${env.TZ}\n```\n\nProperty references use dot notation to indicate array keys, and must be wrapped in `${}`.\n\nExpansion logic:\n\n```php\n\u003c?php\n\n// Set an environmental variable, accessible via ${env.TZ}.\nputenv(\"TZ=ES\");\n\n// Parse a yaml string directly, expanding internal property references.\n$yaml_string = file_get_contents(\"dune.yml\");\n$expanded = \\Grasmash\\YamlExpander\\YamlExpander::parse($yaml_string);\nprint_r($expanded);\n\n// Parse an array, expanding internal property references.\n$array = \\Symfony\\Component\\Yaml\\Yaml::parse(file_get_contents(\"dune.yml\"));\n$expanded = \\Grasmash\\YamlExpander\\YamlExpander::expandArrayProperties($array);\nprint_r($expanded);\n\n// Parse an array, expanding references using both internal and supplementary values.\n$array = \\Symfony\\Component\\Yaml\\Yaml::parse(file_get_contents(\"dune.yml\"));\n$reference_properties = ['book' =\u003e ['publication-year' =\u003e 1965]];\n$expanded = \\Grasmash\\YamlExpander\\YamlExpander::expandArrayProperties($array, $reference_properties);\nprint_r($expanded);\n````\n\nResultant array:\n\n```php\n\u003c?php\n\narray (\n  'type' =\u003e 'book',\n  'book' =\u003e \n  array (\n    'title' =\u003e 'Dune',\n    'author' =\u003e 'Frank Herbert',\n    'copyright' =\u003e 'Frank Herbert 1965',\n    'protaganist' =\u003e 'Paul Atreides',\n    'media' =\u003e \n    array (\n      0 =\u003e 'hardcover',\n    ),\n  ),\n  'characters' =\u003e \n  array (\n    0 =\u003e \n    array (\n      'name' =\u003e 'Paul Atreides',\n      'occupation' =\u003e 'Kwisatz Haderach',\n      'aliases' =\u003e \n      array (\n        0 =\u003e 'Usul',\n        1 =\u003e 'Muad\\'Dib',\n        2 =\u003e 'The Preacher',\n      ),\n    ),\n    1 =\u003e \n    array (\n      'name' =\u003e 'Duncan Idaho',\n      'occupation' =\u003e 'Swordmaster',\n    ),\n  ),\n  'summary' =\u003e 'Dune by Frank Herbert',\n  'product-name' =\u003e 'Dune',\n  'timezone' =\u003e 'ES',\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrasmash%2Fyaml-expander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrasmash%2Fyaml-expander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrasmash%2Fyaml-expander/lists"}