PHPackages                             mireiawen/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. mireiawen/configuration

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

mireiawen/configuration
=======================

Configuration file reader

1.1.0(3y ago)01931MITPHPPHP &gt;=7.4.0

Since Sep 3Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (8)Used By (1)

Configuration
=============

[](#configuration)

Configuration file helpers to read different file formats.

- Namespace: `Mireiawen\Configuration`

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

[](#requirements)

- PHP 7.3 or later
- Extensions depending on needed file types:
    - JSON
    - YAML

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

[](#installation)

You can clone or download the code from the [GitHub repository](https://github.com/Mireiawen/configuration) or you can use composer: `composer require mireiawen/configuration`

Example
-------

[](#example)

```
$configuration = new Mireiawen\Configuration\JSON('config.json');
$hostname = $configuration->GetString('hostname');
$port = $configuration->GetInt('port');
```

JSON specific methods
---------------------

[](#json-specific-methods)

### \_\_construct

[](#__construct)

JSON class constructor

```
Configuration::__construct(string $filename)
```

#### Arguments

[](#arguments)

TypeNameDescription**string**`$filename`The JSON file name to read#### Exceptions thrown

[](#exceptions-thrown)

TypeDescription`MissingExtension`When expected extensions are not available`InvalidFile`When the configuration file is missing or not readableYAML specific methods
---------------------

[](#yaml-specific-methods)

### \_\_construct

[](#__construct-1)

YAML class constructor

```
Configuration::__construct(string $filename)
```

#### Arguments

[](#arguments-1)

TypeNameDescription**string**`$filename`The YAML file name to read#### Exceptions thrown

[](#exceptions-thrown-1)

TypeDescription`MissingExtension`When expected extensions are not available`InvalidFile`When the configuration file is missing or not readableCommon interface methods
------------------------

[](#common-interface-methods)

- [Has](#Has)
- [Get](#Get)
- [GetString](#GetString)
- [GetInt](#GetInt)
- [GetFloat](#GetFloat)
- [GetBool](#GetBool)
- [GetAsString](#GetAsString)
- [GetAsInt](#GetAsInt)
- [GetAsFloat](#GetAsFloat)
- [GetAsBool](#GetAsBool)

---

### Has

[](#has)

Check if the configuration variable exists and is set.

```
Configuration::Has(string $key) : bool
```

#### Arguments

[](#arguments-2)

TypeNameDescription**string**`$key`The key to check#### Return value

[](#return-value)

TypeDescription**bool**`TRUE` if the value exists and is set, `FALSE` if the value does not exist---

### Get

[](#get)

Get the configuration variable and return its value, or default if it is not set.

```
Configuration::Get(string $key, mixed $default) : mixed
```

#### Arguments

[](#arguments-3)

TypeNameDescription**string**`$key`The key to retrieve**mixed**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-1)

TypeDescription**mixed**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-2)

TypeDescription`MissingValue`In case the key is not available and default value is not set---

### GetString

[](#getstring)

Get the configuration variable and return its value, or default if it is not set, and validating the type

```
Configuration::GetString(string $key, string|null $default) : string
```

#### Arguments

[](#arguments-4)

TypeNameDescription**string**`$key`The key to retrieve**string|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-2)

TypeDescription**string**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-3)

TypeDescription`MissingValue`In case the key is not available and default value is not set`\TypeError`In case the value is not of type string---

### GetInt

[](#getint)

Get the configuration variable and return its value, or default if it is not set, and validating the type

```
Configuration::GetInt(string $key, int|null $default) : int
```

#### Arguments

[](#arguments-5)

TypeNameDescription**string**`$key`The key to retrieve**int|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-3)

TypeDescription**int**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-4)

TypeDescription`MissingValue`In case the key is not available and default value is not set`\TypeError`In case the value is not of type int---

### GetFloat

[](#getfloat)

Get the configuration variable and return its value, or default if it is not set, and validating the type

```
Configuration::GetFloat(string $key, float|null $default) : float
```

#### Arguments

[](#arguments-6)

TypeNameDescription**string**`$key`The key to retrieve**float|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-4)

TypeDescription**float**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-5)

TypeDescription`MissingValue`In case the key is not available and default value is not set`\TypeError`In case the value is not of type float---

### GetBool

[](#getbool)

Get the configuration variable and return its value, or default if it is not set, and validating the type

```
Configuration::GetBool(string $key, bool|null $default) : bool
```

#### Arguments

[](#arguments-7)

TypeNameDescription**string**`$key`The key to retrieve**bool|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-5)

TypeDescription**bool**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-6)

TypeDescription`MissingValue`In case the key is not available and default value is not set`\TypeError`In case the value is not of type bool---

### GetAsString

[](#getasstring)

Get the configuration variable and return its value, or default if it is not set, and casting the return value to correct type

```
Configuration::GetAsString(string $key, string|null $default) : string
```

#### Arguments

[](#arguments-8)

TypeNameDescription**string**`$key`The key to retrieve**string|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-6)

TypeDescription**string**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-7)

TypeDescription`MissingValue`In case the key is not available and default value is not set---

### GetAsInt

[](#getasint)

Get the configuration variable and return its value, or default if it is not set, and casting the return value to correct type

```
Configuration::GetAsInt(string $key, int|null $default) : int
```

#### Arguments

[](#arguments-9)

TypeNameDescription**string**`$key`The key to retrieve**int|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-7)

TypeDescription**int**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-8)

TypeDescription`MissingValue`In case the key is not available and default value is not set---

### GetAsFloat

[](#getasfloat)

Get the configuration variable and return its value, or default if it is not set, and casting the return value to correct type

```
Configuration::GetAsFloat(string $key, float|null $default) : float
```

#### Arguments

[](#arguments-10)

TypeNameDescription**string**`$key`The key to retrieve**float|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-8)

TypeDescription**float**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-9)

TypeDescription`MissingValue`In case the key is not available and default value is not set---

### GetAsBool

[](#getasbool)

Get the configuration variable and return its value, or default if it is not set, and casting the return value to correct type

```
Configuration::GetAsBool(string key, bool|null default) : bool
```

#### Arguments

[](#arguments-11)

TypeNameDescription**string**`$key`The key to retrieve**bool|null**`$default`The default value for the key, set to `NULL` to throw error if key is not set#### Return value

[](#return-value-9)

TypeDescription**bool**The value of the key, or the provided default if key is not set#### Exceptions thrown

[](#exceptions-thrown-10)

TypeDescription`MissingValue`In case the key is not available and default value is not set

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Recently: every ~249 days

Total

7

Last Release

1430d ago

Major Versions

0.3.1 → 1.0.02022-06-14

PHP version history (2 changes)0.1.0PHP &gt;=7.3.0

1.1.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b939943c063fd46acb5c8cd353ed8f69511ea19527d9196a09c382e828847bc?d=identicon)[Mireiawen](/maintainers/Mireiawen)

---

Top Contributors

[![Mireiawen](https://avatars.githubusercontent.com/u/11092031?v=4)](https://github.com/Mireiawen "Mireiawen (9 commits)")

### Embed Badge

![Health badge](/badges/mireiawen-configuration/health.svg)

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

###  Alternatives

[mis/yii2-ide-helper

Yii2 IDE Helper, generates correct PHPDocs for all components, to improve auto-completion.

1664.2k3](/packages/mis-yii2-ide-helper)[larament/seokit

A complete SEO package for Laravel, covering everything from meta tags to social sharing and structured data.

411.9k](/packages/larament-seokit)

PHPackages © 2026

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