PHPackages                             hurtcode/configure-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hurtcode/configure-yaml

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hurtcode/configure-yaml
=======================

Yaml based library for configurations

1.0.1(4y ago)08MITPHPPHP 8.\*

Since Jun 22Pushed 4y agoCompare

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

READMEChangelog (2)Dependencies (5)Versions (6)Used By (0)

Config YAML
===========

[](#config-yaml)

---

This library is YAML implementation of [config](https://github.com/hurtcode/config) library. It uses yaml file format to take care of application configurations.

List of abilities of library:

- Implenent bunch of special tag, that help create complex multifile configurations
- The flexibility to add custom logic to compile files

### Usage example:

[](#usage-example)

Create configuration files. All files locates in one configuration directory.

```
# main.yaml
!merge
- !sub common/base
- !env base

# commone/base.yaml
id: 'accounting'
basePath: !var
  key: baseDir
  value: !call
    name: dirname
    args: !interpret $_SERVER['DOCUMENT_ROOT']
components:
  db:
    class: App/Connection/DbClass
  log:
    class: App/Logger
  security:
    class: App/Common/Security

# dev/base.yaml
components:
  db:
    connection:
      port: '5543'
      host: 'localhost'
  log:
    targets: [ 'DEBUG', 'TEST', 'INFO' ]
  security:
    keyDir: !concatenate
      - !var baseDir
      - /kyes/public
```

Than create [configurator class](https://github.com/hurtcode/config/blob/master/src/Configurator.php)with [config resources](https://github.com/hurtcode/config-yaml/blob/master/src/Config.php)and [Yaml compiler](https://github.com/hurtcode/config-yaml/blob/master/src/Config.php).

```
$config = new \Hurtcode\Config\Yaml\Config('config/diractory/path', 'entpryPointFile');
$compiler = new \Hurtcode\Config\Yaml\Compiler(
    new \Hurtcode\Config\Yaml\Tag\AbstractTagProcessorFactory(
        new \Hurtcode\Config\Yaml\Tag\TagProcessorMap()
    )
);

$applicationConfigs = (new \Hurtcode\Config\Configurator($config, $compiler))->run();
```

As result we recieves one php array with configurations

```
[
    'id' => 'accounting',
    'basePath' => '/var/httpd/sites/example',
    'components' => [
        'db' => [
            'class' => 'App/Connection/DbClass',
            'connection' => [
                'port' => '5543',
                'host' => 'localhost'
            ],
        ],
        'log' => [
            'class' => 'App/Logger',
            'targets' => [
                'DEBUG',
                'TEST',
                'INFO'
            ]
        ],
        'security' => [
            'class' => 'App/Common/Security',
            'keyDir' => '/var/httpd/sites/example/kyes/public'
        ]
    ]
];
```

---

### Library work description

[](#library-work-description)

This labrary is baseed on [Symfony's YAML](https://github.com/symfony/yaml) and Yaml tags. All tags do specific logic, like creating configuration variables or string concatanating. Tag functionality is depends on two interfaces TagProcessorFactoryInterface, that creates processor class for curtain tag and TagProcessorsMapInterface, that need to tied tag with its processor class ( it is needed only for base TagProcessorFactoryInterface - AbstractTagProcessorFactory). So if need more specific tag or another processing logic make own implementation of that interfaces

By defualt Config YAML processes next tags:

- call
- env
- concatenate
- merge
- interpret
- sub
- get
- var

All this tags contains in [tag list class](https://github.com/hurtcode/config-yaml/blob/master/src/Tag/Tag.php)

### Tags and processors

[](#tags-and-processors)

**Callable processor**

---

**!call**

Helps to call php function in configurations. Function name takes from `name` kay of tag's value Also you can pass arguments, by `args` key

Tag rules:

- Value has to contain 'name' key.
- 'name' has to be string
- If you pass args as array it has to be indexed (without string keys)

*Example:*

```
!call
name: substr
args:
 - string
 - 0
 - 3
```

**Sub configuration processor**

---

**!sub**

This processor compiles new configuration and returns it in place where the tag has been used. The configuration file path is relative to the path to the configuration folder

Tag rules:

- Value has to be string

*Example:*

```
!sub path/in/depth/file
```

**Environment processor**

---

**!env**

This processor takes configuration of from environment directory and compiles it like sub configuration processor. Environment directory can be passed from di container. By default environment is 'dev'.

Tag rules:

- Value has to be string

*Example:*

```
!env config
```

**Merge tag processor**

---

**!merge**

Merges tag values in one array. Uses Yiisoft/ArrayHelper.

Tag rules:

- Tag value has to be array or list
- Tag has to contain at least 2 element
- Each element has be array or list

*Example:*

```
!merge
- [ some value, another value ]
- { key: value, anotherKey: another value }
```

**Concatenate processor**

---

**!concatenate**

Concatenate processor takes list of strings and sums it in one

Tag rules:

- Value has to be array of string

*Example:*

```
!concatenate
- some
- string
- is
```

**Interpret processor**

---

**!interpret**

This processor interprets incoming expression as php code. Be careful with this. Incoming strings wraps by template `return {value};` and sends in `eval` function.

Tag rules:

- Value has to be string

*Example:*

```
!interpret '$_SERVER['REQUEST_TIME']'
```

**Variable processor**

---

**!var**

This processor provides ability to create global configuration variables in yaml. It has two work modes: 1) Set mode; 2) Get mode.

Tag rules:

- Value has to contain `key` and `value` (IF YOU WANT SET)
- `Key` has to be string (ONLY SET MODE)
- Value has to be string.
- Value has to be in 'container'. It means you has to set variable before call it!.

*Example:*

```
# set var
- !var { set: variable, value: some value' }
# get var
- !var variable
```

**Get processor**

---

**!get**

Get processor helps to get some curtain value from another configuration or list. To use it you have to specify `key` ( what you want) and `from` (where from need to get).

Tag rules:

- Value has to be list with `key` and `from` keys.
- `key` has to be string (for associative array) or int (for indexed array)
- `from` has to be array or list

*Example:*

```
!get { key:element, from: { element: value } }
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~159 days

Total

2

Last Release

1628d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57592875?v=4)[Kirill K](/maintainers/mislant)[@mislant](https://github.com/mislant)

---

Top Contributors

[![mislant](https://avatars.githubusercontent.com/u/57592875?v=4)](https://github.com/mislant "mislant (7 commits)")

---

Tags

helperconfigyamlconfigurations

### Embed Badge

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

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

###  Alternatives

[clausnz/php-helpers

A Collection of useful php helper functions.

388.7k](/packages/clausnz-php-helpers)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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