PHPackages                             sauls/options-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. sauls/options-resolver

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

sauls/options-resolver
======================

Symfony options resolver with multi dimensional array support

v1.0.2(5y ago)16.1k2MITPHPPHP &gt;=7.4CI failing

Since Feb 18Pushed 5y agoCompare

[ Source](https://github.com/sauls/options-resolver)[ Packagist](https://packagist.org/packages/sauls/options-resolver)[ RSS](/packages/sauls-options-resolver/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (4)Versions (5)Used By (2)

Sauls OptionsResolver
=====================

[](#sauls-optionsresolver)

[![Build Status](https://camo.githubusercontent.com/9406cee561ac2c93ef1102fdc41f19d6e111e9f0e46a8869e3a1507d921fc05c/68747470733a2f2f7472617669732d63692e6f72672f7361756c732f6f7074696f6e732d7265736f6c7665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sauls/options-resolver)[![Packagist](https://camo.githubusercontent.com/1c0312689607a8e4d8911d8853bcefb13e377962370f2f88083436d05baa5373/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361756c732f6f7074696f6e732d7265736f6c7665722e737667)](https://packagist.org/packages/sauls/options-resolver)[![Total Downloads](https://camo.githubusercontent.com/4fab83037a832c8e45512ffbf3588b2140aafcde6ed12239c11ba39c8c88c245/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7361756c732f6f7074696f6e732d7265736f6c7665722e737667)](https://packagist.org/packages/sauls/options-resolver)[![Coverage Status](https://camo.githubusercontent.com/4aac40c4c2a51492a1224913f60501f280f61d8be77e1888a69d629f5aef968f/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f7361756c732f6f7074696f6e732d7265736f6c7665722e737667)](https://coveralls.io/github/sauls/options-resolver?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/512fd3e03312f7fe297700ff36152559ddf59632d8402b7182d22a41930594e2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7361756c732f6f7074696f6e732d7265736f6c7665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sauls/options-resolver/?branch=master)[![License](https://camo.githubusercontent.com/6b31200f161c6d822bac560fd98df3c2c4007eb1f936aedc1494687cef23bdcf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7361756c732f6f7074696f6e732d7265736f6c7665722e737667)](https://packagist.org/packages/sauls/options-resolver)

[Symfony OptionsResolver](https://symfony.com/doc/current/components/options_resolver.html) with multi dimensional array support

Requirements
------------

[](#requirements)

PHP &gt;= 7.2

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

[](#installation)

### Using composer

[](#using-composer)

```
$ composer require sauls/options-resolver
```

### Apppend the composer.json file manually

[](#apppend-the-composerjson-file-manually)

```
{
    "require": {
        "sauls/options-resolver": "^1.0"
    }
}
```

Usage
-----

[](#usage)

Standard usage can be found at [Symfony OptionsResolver official documentation](https://symfony.com/doc/current/components/options_resolver.html).

The associative array support is added by using a `dot notation` array indexes.

### Defining options

[](#defining-options)

To define the associative options, use `dot notated` array indexes.

```
$resolver->setDefined['nested.name', 'nested.value', 'nested.deep.type'];
```

### Adding allowed types

[](#adding-allowed-types)

Allowed types are added using `dot notation` index.

```
$resolver->addAllowedType('nested.name', ['string']);
$resolver->addAllowedType('nested.value', ['int']);
```

### Adding allowed values

[](#adding-allowed-values)

Allowed values are added using `dot notation` index.

```
$resolver->addAllowedValues('nested.deep.type', ['one', 'two', 'three']);
```

### Default option values

[](#default-option-values)

Default options can be added as `dot notation` index or `associative array`.

```
$resolver->setDefaults(
    [
        'nested.name' => 'Hello world!',
        'nested.value' => 100,
        'nested.deep.type' => 'one',
    ]
);

// Or

$resolver->setDefaults(
    [
        'nested' => [
            'name' => 'Hello world!',
            'value' => 100,
            'deep' => [
                'type' => 'one',
            ],
        ],
    ]
);
```

### Resolving options

[](#resolving-options)

Passing array to resolve options can contain either the `dot notation` indexes or `associative` array.

```
$resolver->resolve(
    [
        'nested.name' => 'Resolve me!',
        'nested.value' => 500,
        'nested.deep.type' => 'two',
    ]
);

// Or

$resolver->resolve(
    [
        'nested' => [
            'name' => 'Resolve me!',
            'value' => 500,
            'deep' => [
                'type' => 'two',
            ],
        ]
    ]
);
```

Exceptions
----------

[](#exceptions)

All exceptions will return what is wrong with your associative option using `dot notation`. For example:

> The option "nested.deep.type" with value "four" is invalid. Accepted values are: "one", "two", "three".

> The option "nested.value" with value "wrong" is expected to be of type "int", but is of type "string".

> The required option "nested.value" is missing.

> The option "nested.deep.nmae" does not exist. Defined options are: "nested.deep.name", "nested.name", "nested.type", "nested.value", "text", "type".

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

2094d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v1.x-devPHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![sauls](https://avatars.githubusercontent.com/u/7901434?v=4)](https://github.com/sauls "sauls (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sauls-options-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/sauls-options-resolver/health.svg)](https://phpackages.com/packages/sauls-options-resolver)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[symfony/rate-limiter

Provides a Token Bucket implementation to rate limit input and output in your application

26847.2M147](/packages/symfony-rate-limiter)[symfony/ldap

Provides a LDAP client for PHP on top of PHP's ldap extension

1407.5M46](/packages/symfony-ldap)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[phpbench/container

Simple, configurable, service container.

1512.9M6](/packages/phpbench-container)[symfony/ux-toggle-password

Toggle visibility of password inputs for Symfony Forms

26508.0k5](/packages/symfony-ux-toggle-password)

PHPackages © 2026

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