PHPackages                             susina/param-resolver - 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. susina/param-resolver

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

susina/param-resolver
=====================

Resolve parameters inside a configuration array

v0.5(1y ago)141511Apache-2.0PHPPHP &gt;=8.2CI passing

Since Aug 12Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

Parameter Resolver
==================

[](#parameter-resolver)

[![Test Suite](https://github.com/susina/param-resolver/actions/workflows/test.yml/badge.svg)](https://github.com/susina/param-resolver/actions/workflows/test.yml/badge.svg)[![Maintainability](https://camo.githubusercontent.com/b7a358b01ff05e79e17d2fc3ef878df0c37a3a7c465462cc7b525a9a760fc037/68747470733a2f2f716c74792e73682f6261646765732f31356230383536362d376537612d343663612d623132302d3265323461663936646538332f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/susina/projects/param-resolver)[![Code Coverage](https://camo.githubusercontent.com/652a31a71b3031f2193e4403c900c356e7cffe9875e2ef82b783182fcc9c0027/68747470733a2f2f716c74792e73682f6261646765732f31356230383536362d376537612d343663612d623132302d3265323461663936646538332f746573745f636f7665726167652e737667)](https://qlty.sh/gh/susina/projects/param-resolver)

ParamResolver is a small class to resolve parameters in configuration arrays. It's heavily inspired on [Symfony ParameterBag](src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php) class.

Installation
------------

[](#installation)

Install the library via composer:

`composer require susina/param-resolver`

Usage
-----

[](#usage)

In a configuration array, it can be useful to define some parameters.

A parameter is a previously defined property, put between % special character. When ParamResolver found a parameter, it simply replaces its placeholder with the previously defined value. In the following example, suppose you have a json configuration file:

```
// configuration.json
{
    "library": {
        "project": "AwesomeProject"
    },
    "paths": {
        "projectDir": "/home/%project%"
    }
}
```

First of all you have to convert it into an array, then you can resolve the parameters:

```
