PHPackages                             arhframe/yamlarh - 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. [Framework](/categories/framework)
4. /
5. arhframe/yamlarh

ActiveLibrary[Framework](/categories/framework)

arhframe/yamlarh
================

Inject data and import other formatted file into your formatted file.

1.1.19(10y ago)244.5k↓31.3%3MITPHP

Since Jan 27Pushed 10y agoCompare

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

READMEChangelog (10)Dependencies (3)Versions (17)Used By (3)

Yamlarh
=======

[](#yamlarh)

[![Build Status](https://camo.githubusercontent.com/b4792363338a5b203b188c32bfa4d89e044b887c4629a4bb7b68c4081af7ac45/68747470733a2f2f7472617669732d63692e6f72672f6172686672616d652f79616d6c6172682e737667)](https://travis-ci.org/arhframe/yamlarh) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/247b4c8afecf9d8b23abfd3831ee34e5187e306a18fcff50f462017892bc1ba5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6172686672616d652f79616d6c6172682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/arhframe/yamlarh/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/4f506b8de90b5e02658d3d3d58cfd9477a3025956a5004952b0bb014c0d0a9e6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6172686672616d652f79616d6c6172682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/arhframe/yamlarh/?branch=master) [![SensioLabsInsight](https://camo.githubusercontent.com/b5b4b1f2bf2708261ae9de86fc37d95bdbc65846d59f95d5e58160d76d99bfca/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31326538323034362d313565352d343832612d626332352d3762323866653064346566622f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/12e82046-15e5-482a-bc25-7b28fe0d4efb)

Yamlarh is now just a name, with this tool you can inject complex data or other formatted files in a formatted file (as `json`, `xml` or `yaml`).

You can inject into your formatted file:

- object
- constant from scope
- Variable from global scope
- Variable from formatted file

You can also import other formatted file inside a formatted file file for overriding

Installation
============

[](#installation)

Through Composer, obviously:

```
{
    "require": {
        "arhframe/yamlarh": "1.*"
    }
}
```

Usage
=====

[](#usage)

```
use Arhframe\Yamlarh\Yamlarh;

$yamlarh = new Yamlarh(__DIR__.'/path/to/formatted/file');
$array = $yamlarh->parse();
```

Exemple
=======

[](#exemple)

Variable injection
------------------

[](#variable-injection)

Variable injection is hierarchical, it will find in this order:

1. In the yaml file with import
2. In your global scope
3. In your constants
4. In accessible variables set in yamlarh

Yaml file:

```
arhframe:
  myvar1: test
  myvar2: %arhframe.myvar1%
  myvar3: %var3%
  myvar4: %VARCONSTANT%
  myvar5: %addedInYamlarh%
```

Or in xml:

```

        test
        %arhframe.myvar1%
        %var3%
        %VARCONSTANT%
        %addedInYamlarh%

```

Or in json:

```
{
  "arhframe": {
    "myvar1": "test",
    "myvar2": "%arhframe.myvar1%",
    "myvar3": "%var3%",
    "myvar4": "%VARCONSTANT%",
    "myvar5": "%addedInYamlarh%"
  }
}
```

Php file:

```
use Arhframe\Yamlarh\Yamlarh;
$var3 = 'testvar';
define('VARCONSTANT', 'testconstant');
$yamlarh = new Yamlarh(__DIR__.'/test.yml');
$yamlarh->addAccessibleVariable("addedInYamlarh", "var added");
$array = $yamlarh->parse();
echo print_r($array);
```

Output:

```
  Array
  (
      [arhframe] => Array
          (
              [myvar1] => test
              [myvar2] => test
              [myvar3] => testvar
              [myvar4] => testconstant
              [myvar5] => var added
          )
  )

```

Object injection
----------------

[](#object-injection)

It use [snakeyml](https://code.google.com/p/snakeyaml/wiki/Documentation#Compact_Object_Notation) (yaml parser for java) style:

```
arhframe:
  file: !! Arhframe.Util.File(test.php) #will instanciate this: Arhframe\Util\File('test.php') in file var after parsing
```

Import
------

[](#import)

Import are also hierarchical the last one imported will override the others.

Use yar-import by default in your file:

file1.xml

```

        var

    arhframe
    file2.yml

```

file2.yml

```
arhframe:
  var1: varoverride
test2: var3
```

After parsing file1.xml, output will look like (just to have a better format it's show yml):

```
arhframe:
  var1: varoverride
test: arhframe
test2: var3
```

Include
-------

[](#include)

You can include a yaml file into another:

file1.yml

```
arhframe:
  var1: var
test:
  yar-include:
    - file2.yml #you can use a relative path to your yaml file or an absolute
```

file2.yml

```
test2: var3
```

After parsing file1.yml, output will look like:

```
arhframe:
  var1: var
test:
  test2: var3
```

**Note**: You can look at these [tests](https://github.com/arhframe/yamlarh/blob/master/tests/Arhframe/Yamlarh/YamlarhTest.php) to know what you can also do.

Extensible
==========

[](#extensible)

Add a node
----------

[](#add-a-node)

After parsing and importing but before injecting yamlarh can run your extension.

You have to create a new class which extends `Arhframe\Yamlarh\YamlarhNode` and add it to your yamlarh instance like this:

```
//create your yamalarh instance before
$yamlarh->addNode("myNodeName", new MyYamlarhNode());
```

Now you can use (for this example) `yar-myNodeName` in your formated file.

**Note**: the `yar-include` is a node take look at [IncludeYamlarhNode](https://github.com/arhframe/yamlarh/blob/master/src/Arhframe/Yamlarh/YamlarhNode/IncludeYamlarhNode.php) to have a good example.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~40 days

Recently: every ~46 days

Total

16

Last Release

3894d ago

### Community

Maintainers

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

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

---

Top Contributors

[![ArthurHlt](https://avatars.githubusercontent.com/u/5410858?v=4)](https://github.com/ArthurHlt "ArthurHlt (40 commits)")

---

Tags

frameworkyamlinjectinjectorArhframe

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arhframe-yamlarh/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[sifophp/sifo

SIFO framework.

5675.6k](/packages/sifophp-sifo)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

338.9k1](/packages/davidepastore-slim-config)

PHPackages © 2026

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