Load your Laravel config files using yaml. Forked from https://github.com/antonioribeiro/yaml
ninthday/yaml is a Laravel package for load your laravel config files using yaml. forked from https://github.com/antonioribeiro/yaml.
It currently has 0 GitHub stars and 1.078 downloads on Packagist (latest version v1.4.0).
Install it with composer require ninthday/yaml.
Discover more Laravel packages by ninthday
or browse all Laravel packages to compare alternatives.
Last updated
Config files getting bigger, harder to maintain and look at, every day. Why not just use YAML to load them?
Yaml::loadToConfig(config_path('myapp.yml'), 'my-app-conf');
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')
repository: "{{ env('APP_NAME') }}"
path: "{{ storage_path('app') }}"
{{'format.version'}}
build:
mode: git-local #### other modes: git-remote or number
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.
Via Composer
$ composer require ninthday/yaml
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('ninthday.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');
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(\Ninthday\Yaml\Package\Support\Parser::class, \Ninthday\Yaml\Package\Support\PeclParser::class);
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: ninthday-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
This package is licensed under the MIT License - see the LICENSE file for details
Pull requests and issues are welcome.