All Projects โ†’ antonioribeiro โ†’ yaml

antonioribeiro / yaml

Licence: MIT License
A Laravel YAML parser and config loader

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yaml

Vscode Data Preview
Data Preview ๐Ÿˆธ extension for importing ๐Ÿ“ค viewing ๐Ÿ”Ž slicing ๐Ÿ”ช dicing ๐ŸŽฒ charting ๐Ÿ“Š & exporting ๐Ÿ“ฅ large JSON array/config, YAML, Apache Arrow, Avro, Parquet & Excel data files
Stars: โœญ 245 (+145%)
Mutual labels:  config, yaml
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: โœญ 20 (-80%)
Mutual labels:  config, yaml
luban
ไฝ ็š„ๆœ€ไฝณๆธธๆˆ้…็ฝฎ่งฃๅ†ณๆ–นๆกˆ {excel, csv, xls, xlsx, json, bson, xml, yaml, lua, unity scriptableobject} => {json, bson, xml, lua, yaml, protobuf(pb), msgpack, flatbuffers, erlang, custom template} data + {c++, java, c#, go(golang), lua, javascript(js), typescript(ts), erlang, rust, gdscript, protobuf schema, flatbuffers schema, custom template} codeใ€‚
Stars: โœญ 1,660 (+1560%)
Mutual labels:  config, yaml
Simple Settings
A simple way to manage your project settings.
Stars: โœญ 165 (+65%)
Mutual labels:  config, yaml
Slim-Config
A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.
Stars: โœญ 28 (-72%)
Mutual labels:  config, yaml
Config
๐Ÿ“ Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Goๅบ”็”จ้…็ฝฎๅŠ ่ฝฝ็ฎก็†๏ผŒๆ”ฏๆŒๅคš็งๆ ผๅผ๏ผŒๅคšๆ–‡ไปถๅŠ ่ฝฝ๏ผŒ่ฟœ็จ‹ๆ–‡ไปถๅŠ ่ฝฝ๏ผŒๆ”ฏๆŒๆ•ฐๆฎๅˆๅนถ๏ผŒ่งฃๆž็Žฏๅขƒๅ˜้‡ๅ
Stars: โœญ 225 (+125%)
Mutual labels:  config, yaml
exenv
Exenv makes loading environment variables from external sources easy.
Stars: โœญ 35 (-65%)
Mutual labels:  config, yaml
Config Lite
A super simple & flexible & useful config module.
Stars: โœญ 78 (-22%)
Mutual labels:  config, yaml
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: โœญ 86 (-14%)
Mutual labels:  config, yaml
theconf
Python Package for Managing Configurations
Stars: โœญ 35 (-65%)
Mutual labels:  config, yaml
Cfgdiff
diff(1) all your configs
Stars: โœญ 138 (+38%)
Mutual labels:  config, yaml
yaask
Make your yaml configurable with interactive configurations!
Stars: โœญ 15 (-85%)
Mutual labels:  config, yaml
Gray Matter
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Stars: โœญ 2,105 (+2005%)
Mutual labels:  config, yaml
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: โœญ 225 (+125%)
Mutual labels:  config, yaml
Dynaconf
Configuration Management for Python โš™
Stars: โœญ 2,082 (+1982%)
Mutual labels:  config, yaml
cfg-rs
A Configuration Library for Rust Applications
Stars: โœญ 18 (-82%)
Mutual labels:  config, yaml
Mconfig
MCONFIG is a lightweight Golang library for integrating configs files like (json, yml, toml) and environment variables into one config struct.
Stars: โœญ 28 (-72%)
Mutual labels:  config, yaml
Hiyapyco
HiYaPyCo - A Hierarchical Yaml Python Config
Stars: โœญ 58 (-42%)
Mutual labels:  config, yaml
transfer
Converts from one encoding to another. Supported formats HCL โ‡„ JSON โ‡„ YAMLโ‡„TOMLโ‡„XMLโ‡„plistโ‡„pickleโ‡„properties ...
Stars: โœญ 70 (-30%)
Mutual labels:  config, yaml
goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: โœญ 80 (-20%)
Mutual labels:  config, yaml

YAML

A Laravel YAML parser and config loader

Latest Stable Version License Code Quality Build

Coverage StyleCI SensioLabsInsight

Rationale

Config files getting bigger, harder to maintain and look at, every day. Why not just use YAML to load them?

Which one is cleaner?

Key features

Load one file to Laravel config

Yaml::loadToConfig(config_path('myapp.yml'), 'my-app-conf');

Or a whole directory, recursively, so all those files would be loaded with a single command

Yaml::loadToConfig(config_path('myapp'), 'my-app-conf');

To load a directory with all your config files:

.
โ””โ”€โ”€ myapp
    โ”œโ”€โ”€ multiple
    โ”‚   โ”œโ”€โ”€ alter.yml
    โ”‚   โ”œโ”€โ”€ app.yml
    โ”‚   โ””โ”€โ”€ second-level
    โ”‚       โ””โ”€โ”€ third-level
    โ”‚           โ”œโ”€โ”€ alter.yml
    โ”‚           โ””โ”€โ”€ app.yml
    โ”œโ”€โ”€ single
        โ””โ”€โ”€ single-app.yml

Then you would just have to use it like you usually do in Laravel

config('my-app-conf.multiple.second-level.third-level.alter.person.name')

Execute functions, like in the usual Laravel PHP array config.

repository: "{{ env('APP_NAME') }}"
path: "{{ storage_path('app') }}"

Config values can reference config keys, you just have to quote it this way:

{{'format.version'}}

You can add comments to your YAML files, something JSON wouldn't let you do

build:
  mode: git-local  #### other modes: git-remote or number

Parser and dumper methods

In case you need to deal with YAML directly, you can use these public methods:

Yaml::parse($input, $flags) // Parses YAML into a PHP value.

Yaml::parseFile($filename, $flags) // Parses a YAML file into a PHP value.

Yaml::dump($input, $inline, $indent, $flags) // Dumps a PHP value to a YAML string.

Which are simple bridges to Symfony's YAML.

Install

Via Composer

$ composer require pragmarx/yaml

Using

Publish your package as you would usually do:

$this->publishes([
    __DIR__.'/../config/version.yml' => $this->getConfigFile(),
]);

Load the configuration in your boot() method:

$this->app
     ->make('pragmarx.yaml')
     ->loadToConfig($this->getConfigFile(), 'my-package');

Or use the Facade:

Yaml::loadToConfig(config_path('myapp.yml'), 'my-package');

And it's merged to your Laravel config:

config('my-package.name');

Utilize PECL YAML

To utilize the PECL YAML, you should install the PECL YAML extension and register the binding in the register() method of your service provider:

$this->app->bind(\PragmaRX\Yaml\Package\Support\Parser::class, \PragmaRX\Yaml\Package\Support\PeclParser::class);

Example

This is a YAML file from another package using this package:

current:
  major: 1
  minor: 0
  patch: 0
  format: "{$major}.{$minor}.{$patch}"
cache:
  enabled: true
  key: pragmarx-version
build:
  mode: git-local # git-remote or number
  number: 701031
  git-local: "git rev-parse --verify HEAD"
  git-remote: "git ls-remote {$repository} refs/heads/master"
  repository: "{{ env('APP_GIT_REPOSITORY') }}"
  length: 6
format:
  version: "{$major}.{$minor}.{$patch} (build {$build})"
  full: "version {{'format.version'}}"
  compact: "v{$major}.{$minor}.{$patch}-{$build}"
  ## add as many formats as you need

Minimum requirements

  • Laravel 5.5
  • PHP 7.0

Author

Antonio Carlos Ribeiro

License

This package is licensed under the MIT License - see the LICENSE file for details

Contributing

Pull requests and issues are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].