PHPackages                             ninthday/yaml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ninthday/yaml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ninthday/yaml
=============

Load your Laravel config files using yaml. Forked from https://github.com/antonioribeiro/yaml

v1.4.0(2y ago)0732—0%1MITPHPPHP &gt;=7.0

Since Feb 25Pushed 2y agoCompare

[ Source](https://github.com/ninthday/yaml)[ Packagist](https://packagist.org/packages/ninthday/yaml)[ RSS](/packages/ninthday-yaml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (1)

YAML
====

[](#yaml)

### A Laravel YAML parser and config loader

[](#a-laravel-yaml-parser-and-config-loader)

 [![](https://camo.githubusercontent.com/aad51c0cbc12c7ff6d3986a63504901e79af55a249663a59f6a8b4f51ded3261/68747470733a2f2f62756464792e776f726b732f646174612f626c6f672f5f7468756d626e61696c732f79616d6c2d636f7665722e706e67)](https://camo.githubusercontent.com/aad51c0cbc12c7ff6d3986a63504901e79af55a249663a59f6a8b4f51ded3261/68747470733a2f2f62756464792e776f726b732f646174612f626c6f672f5f7468756d626e61696c732f79616d6c2d636f7665722e706e67)

 [![Latest Stable Version](https://camo.githubusercontent.com/9bfb7cd5ba3338d11ce4ade51599ba618f64f91b7baac35fb257e57e858a8834/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696e74686461792f79616d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ninthday/yaml) [![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](/antonioribeiro/yaml/blob/master/LICENSE.md) [![Code Quality](https://camo.githubusercontent.com/da51b452fbb56c57802df1bdc9a26dd3e7ae681dedb6d3e1801f1e0f80de8cf4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616e746f6e696f7269626569726f2f79616d6c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master) [![Build](https://camo.githubusercontent.com/0037b4901bd646021e1e04922991136222b641f2233097dbafe38827a5864a44/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f616e746f6e696f7269626569726f2f79616d6c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master)

 [![Coverage](https://camo.githubusercontent.com/f6f15744e1c56f82f2022193cec91ea0ad7a3650a88c9ea7585d8c2bb0585e7a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616e746f6e696f7269626569726f2f79616d6c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master) [![StyleCI](https://camo.githubusercontent.com/ac5293064e492309ef08caae3258ac3a1ad807ec4ccca08892dcf7b948acba1c/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131323632343433372f736869656c64)](https://styleci.io/repos/112624437) [![SensioLabsInsight](https://camo.githubusercontent.com/fa0b857b6c5ecc894ad87f68536a2cb460696b0fe473cfe517bf34705fb85045/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f37656465376339352d623331622d346561312d393639342d3531623566316439626462382e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/7ede7c95-b31b-4ea1-9694-51b5f1d9bdb8)

Rationale
---------

[](#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?

[](#which-one-is-cleaner)

 [![](docs/yaml-php.png)](docs/yaml-php.png)

Key features
------------

[](#key-features)

### Load one file to Laravel config

[](#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
-------------------------------------------------------------------------------------------

[](#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.

[](#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:

[](#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

[](#you-can-add-comments-to-your-yaml-files-something-json-wouldnt-let-you-do)

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

Parser and dumper methods
-------------------------

[](#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](https://symfony.com/doc/current/components/yaml.html).

Install
-------

[](#install)

Via Composer

```
$ composer require ninthday/yaml
```

Using
-----

[](#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('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');
```

Utilize PECL YAML
-----------------

[](#utilize-pecl-yaml)

To utilize the PECL YAML, you should [install the PECL YAML extension](https://www.php.net/manual/en/yaml.installation.php) 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);
```

Example
-------

[](#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: 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
```

Minimum requirements
--------------------

[](#minimum-requirements)

- Laravel 5.5
- PHP 7.0

Author
------

[](#author)

[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)

License
-------

[](#license)

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

Contributing
------------

[](#contributing)

Pull requests and issues are welcome.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

805d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/babd91a11789e36e19298cee57d35ddaf6f2a4a29a3d6b3f425ff293b5a8e4c5?d=identicon)[ninthday](/maintainers/ninthday)

---

Top Contributors

[![antonioribeiro](https://avatars.githubusercontent.com/u/3182864?v=4)](https://github.com/antonioribeiro "antonioribeiro (106 commits)")[![ngmy](https://avatars.githubusercontent.com/u/864041?v=4)](https://github.com/ngmy "ngmy (6 commits)")[![AraneaDev](https://avatars.githubusercontent.com/u/12177132?v=4)](https://github.com/AraneaDev "AraneaDev (4 commits)")[![ninthday](https://avatars.githubusercontent.com/u/1305972?v=4)](https://github.com/ninthday "ninthday (4 commits)")[![RobertBoes](https://avatars.githubusercontent.com/u/2871897?v=4)](https://github.com/RobertBoes "RobertBoes (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

laravelconfigyaml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ninthday-yaml/health.svg)

```
[![Health](https://phpackages.com/badges/ninthday-yaml/health.svg)](https://phpackages.com/packages/ninthday-yaml)
```

###  Alternatives

[pragmarx/yaml

Load your Laravel config files using yaml

1152.8M29](/packages/pragmarx-yaml)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
