walter-a-jablonowski / super-yaml
Supercharges Symfony YAML
Requires
- symfony/yaml: >=3.4.21
This package is auto-updated.
Last update: 2025-04-28 01:49:16 UTC
README
Supercharges YAML, based on Symfony Yaml, currently adds include feature.
This is a new project, might still need debugging
If you like visit my personal homepage: walter-a-jablonowski.github.io
Usage
composer require walter-a-jablonowski/super-yaml
Basic usage
Simliar symfony yaml
SuperYaml::parse( $yml ); SuperYaml::parseFile( $fil ); SuperYaml::dump( $yml ); SuperYaml::parse( $yml, [ // use symfony flags while parsing 'flags' => ... // difference: additional args as array ]); SuperYaml::dump( $yml, [ // use symfony inline, indent, flags on dumping 'inline' => ... , 'indent' => ... , 'flags' => ... ]);
Include
See demo/demo.php
: one yml file includes 2 yml-files
ANY_KEY: "@file(sub/sub/fil.yml)" "@include [UNIQUE_STRING]": "@file( sub/sub/fil.yml )" # also includes key(s)
[UNIQUE_STRING] = a user defined unique string in case you are using the same key again (yml needs unique keys)
Result:
Replace constant string
See demo/demo.php
sample under construction
ANY_KEY: "@file([REPLACE_STRING]sub/sub/fil.yml)" "@include [UNIQUE_STRING]": "@file( [REPLACE_STRING]sub/sub/fil.yml )" # also includes key(s)
[UNIQUE_STRING] = see above
[REPLACE_STRING] = a string that will be replaced as defined in $rpl argument
SuperYaml::parse( $yml, [ // additional args as array 'rpl' => [ ] ]);
Include conditionally
You may define a list of bool vars that are used to decide wheather a file should be included. Calculate all your values before calling SuperYaml.
See demo/demo.php
sample under construction
"@includeIf(boolVar) [UNIQUE_STRING]:" ANY_VALUE "@includeIf( boolVar ) [UNIQUE_STRING]": "@file( sub/sub/fil.yml )"
[UNIQUE_STRING] = see above
SuperYaml::parse( $yml, [ 'boolVar' => [ ] ]);
Include text
Include just plain text
ANY_KEY: |
some text
@text(sub/sub/fil.yml)
some text
@text( sub/sub/fil2.yml )
Changelog
- 2020 - Fix, readme
- 2020 - Added readme, publication
- 2019 - Added class, improved code
- 2018 - Initial development
LICENSE
Copyright (C) Walter A. Jablonowski 2018-2020, MIT License
Licenses of third party software see credits