PHPackages                             volta-framework/component-configuration - 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. volta-framework/component-configuration

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

volta-framework/component-configuration
=======================================

Provide a component to manage configurations

v1.1.4(2y ago)0371MITPHPPHP &gt;=8.1

Since Jul 1Pushed 2y agoCompare

[ Source](https://github.com/volta-framework/component-configuration)[ Packagist](https://packagist.org/packages/volta-framework/component-configuration)[ Docs](https://github.com/volta-framework/component-configuration)[ RSS](/packages/volta-framework-component-configuration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (1)

Volta Configuration Component
=============================

[](#volta-configuration-component)

- [Volta Configuration Component](#volta-configuration-component-)
    - [Features](#features)
    - [UML Class Diagram](#uml-class-diagram)
    - [Construction](#construction)
    - [Usage](#usage)

Component to manage configurations.

Features
--------

[](#features)

- Different formats: JSON and PHP Array's
- File or memory storage
- Cascading Configurations
- Specify required options
- Specify a set of allowed options (whitelisting)
- Generation of configuration file(\*.json or \*.php) based on Configuration Keys Attribute in code

UML Class Diagram
-----------------

[](#uml-class-diagram)

 ```
classDiagram

    note "SPL = Standard PHP Library"
    namespace Spl {
        class _Throwable {
            &lt;&lt;interface&gt;&gt;
        }
        class _Stringable {
            &lt;&lt;interface&gt;&gt;
        }
        class _Exception
        class _Attribute
        class _ArrayAccess
        class _JsonSerializable
    }

    link Config "https://github.com/volta-framework/component-configuration/blob/main/libraries/Volta/Component/Configuration/Config.php"

    link Key "https://github.com/volta-framework/component-configuration/blob/main/libraries/Volta/Component/Configuration/Key.php"

    link Exception "https://github.com/volta-framework/component-configuration/blob/main/libraries/Volta/Component/Configuration/Exception.php"

    note for Config "Only the most used class members are displayed"

    namespace Volta-Component-Configuration {
        class Exception
        class Key{
            &lt;&lt;Attribute&gt;
        }

        class Config{
            +getOption($key:string, $default:mixed):mixed
            +setOption($key:string, $value:mixed, $overWrite: bool = false):mixed
            +hasOption($key: string): bool
            +setRequiredOptions($requiredOptions: string[]): self
            +setAllowedOptions($allowedOptions: string[]): self
            +setOptions($options: array&lt;string, mixed&gt;|string): self
        }
    }

    _Throwable  _Exception  : extends
    _Throwable  ..|> _Exception : implements
    Key --|>  _Attribute  : extends
    Config ..> Exception : throws
    Config ..> _ArrayAccess : implements
    Config ..> _JsonSerializable : implements

```

      Loading \* *Only the most used class members are displayed in the UML ClassDiagram*
\* *SPL = Standard PHP Library*

Construction
------------

[](#construction)

```
    declare(strict_types=1);

    use Volta\Component\Configuration\Config

    // i. Initialize a Config object with options stored in a *.php file
    $conf = new Config(__DIR__ . '/config/example-config.php');

    // ii. Initialize a Config object with options stored in a *.json file
    $conf = new Config(__DIR__ . '/config/example-config.json');

    // iii. Initialize a Config object with options stored in a json string
    $conf = new Config(
       '{
           "databases": {
             "default": {
               "dsn": "sqlite:/path/to/sqlite/db/file.sqlite"
             }
           }
       }'
    );

    // iv. Initialize a Config object with options stored in a php array
    $conf = new Config(
       [
          'databases' => [
              'default' => [
                  'dsn' => 'sqlite:/path/to/sqlite/db/file.sqlite'
              ]
          ]
      ]
    );

    // v. Adding or overwriting data after initialization can be done with the setOption() method
    //    and accepts all the formats described above. Previous data will be
    //    overwritten. (cascading) configuration
    $conf->setOptions(__DIR__ . '/config/example-config.php')

```

File : `~/config/example-config.php`:

```
declare(strict_types=1);

return [
    'databases' => [
        'default' => [
            'dsn' => 'sqlite:/path/to/sqlite/db/file.sqlite'
        ]
    ]
];
```

File: `~/config/example-config.json`:

```
{
  "databases": {
    "default": {
      "dsn": "sqlite:/path/to/sqlite/db/file.sqlite"
    }
  }
}
```

Usage
-----

[](#usage)

When the Configuration object is initialized values can be retrieved. Best to show with some example code:

```
declare(strict_types=1);

use Volta\Component\Configuration\Config
use Volta\Component\Configuration\Exception as ConfigException
use \PDO

$conf = new Config(__DIR__ . '/config/example-config.php');

// check if we have a database configuration, exit if not
if ($conf->hasOption('databases.default')) {
   exit('No default database settings configured')
}

// The above functionality can also be accomplished by adding (a) required option(s) which
// will generate an exception on failure with the message:
//
//     Required option "databases.default" is missing
//
try{
    $conf = new Config(
        options: __DIR__ . '/config/example-config.php',
        requiredOptions: ['databases.default']
    );
} catch (ConfigException $e) {
    exit($e->getMessage())
}

// We also can set/overwrite a value
$conf->setOption(
    key: 'database.default.password',
    value: null,
    overWrite: true
);

// create PDO object and provide some defaults in case some options are not set
$pdo = new PDO(
    dns: $conf['databases.default.dsn'],
    username: $conf->getOption('databases.default.username', null),
    password: $conf->getOption('databases.default.password'),
    options: $conf->getOption(
        'databases.default.options',
        [
            PDO::ATTR_EMULATE_PREPARES => false,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_CASE => PDO::CASE_NATURAL
        ]
    )
);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Recently: every ~2 days

Total

6

Last Release

946d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0726fbbdcd467b1e1ffc4c7934f712f3b8072e0032942119f0d205df502688c2?d=identicon)[Volta-Rob](/maintainers/Volta-Rob)

---

Top Contributors

[![Demper](https://avatars.githubusercontent.com/u/25136258?v=4)](https://github.com/Demper "Demper (12 commits)")

---

Tags

phpconfiguration

### Embed Badge

![Health badge](/badges/volta-framework-component-configuration/health.svg)

```
[![Health](https://phpackages.com/badges/volta-framework-component-configuration/health.svg)](https://phpackages.com/packages/volta-framework-component-configuration)
```

PHPackages © 2026

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