Load your Laravel config files using yaml
Package Data
Maintainer Username: AntonioCarlosRibeiro
Maintainer Contact: acr@antoniocarlosribeiro.com (Antonio Carlos Ribeiro)
Package Create Date: 2017-11-30
Package Last Update: 2020-05-21
Language: PHP
License: MIT
Last Refreshed: 2020-06-22 15:07:39
Package Statistics
Total Downloads: 362,372
Monthly Downloads: 19,352
Daily Downloads: 343
Total Stars: 73
Total Watchers: 5
Total Forks: 10
Total Open Issues: 1


A Laravel YAML parser and config loader


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


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:


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

  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.


Via Composer

$ composer require pragmarx/yaml


Publish your package as you would usually do:

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

Load the configuration in your boot() method:

     ->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:



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

  major: 1
  minor: 0
  patch: 0
  format: "{$major}.{$minor}.{$patch}"
  enabled: true
  key: pragmarx-version
  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
  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


Antonio Carlos Ribeiro


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


Pull requests and issues are welcome.