PHPackages                             setbased/typed-config - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. setbased/typed-config

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

setbased/typed-config
=====================

A lightweight and strong typed that supports PHP, INI, XML, JSON, and YAML files

2.1.0(1y ago)042.5k↓10.6%14MITPHPPHP &gt;=8.3CI failing

Since Sep 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SetBased/php-typed-config)[ Packagist](https://packagist.org/packages/setbased/typed-config)[ RSS](/packages/setbased-typed-config/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (4)

Strong Typed Config
===================

[](#strong-typed-config)

A lightweight and strong typed configuration file loader that supports PHP, INI, XML, JSON, and YAML files.

This package is a wrapper around [hassankhan/config](https://github.com/hassankhan/config).

SocialLegalReleaseTests[![Gitter](https://camo.githubusercontent.com/7c1a64a746be49efe98697834203a9a46574b334819e2540fbbd5f76438e54ad/68747470733a2f2f6261646765732e6769747465722e696d2f53657442617365642f7068702d74797065642d636f6e6669672e737667)](https://gitter.im/SetBased/php-typed-config?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![License](https://camo.githubusercontent.com/06a9c4f9ea3c1e3ae0fd28794145c3ce8ab711881cb3e18fada2256af92008a2/68747470733a2f2f706f7365722e707567782e6f72672f73657462617365642f74797065642d636f6e6669672f6c6963656e7365)](https://packagist.org/packages/setbased/typed-config)[![Latest Stable Version](https://camo.githubusercontent.com/83921db50a08d37706e49a0ec5f3707b37fdebbebdb1a658df5b7c8130f3ad7d/68747470733a2f2f706f7365722e707567782e6f72672f73657462617365642f74797065642d636f6e6669672f762f737461626c65)](https://packagist.org/packages/setbased/typed-config)
[![Build Status](https://github.com/SetBased/php-typed-config/actions/workflows/unit.yml/badge.svg)](https://github.com/SetBased/php-typed-config/actions/workflows/unit.yml)
[![Code Coverage](https://camo.githubusercontent.com/784962fb5d1a4e69f67c7cc68029a20f5200b650fec426091d5c7a6bee894d47/68747470733a2f2f636f6465636f762e696f2f67682f53657442617365642f7068702d74797065642d636f6e6669672f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/SetBased/php-typed-config)Manual
======

[](#manual)

Instantiating Strong Typed Config
---------------------------------

[](#instantiating-strong-typed-config)

Creating an instance of Strong Typed Config requires passing an instance of `Noodlehaus\Config`:

```
use Noodlehaus\Config;
use SetBased\Config\TypedConfig;

$config = new TypedConfig(new Config('config.json'));
```

Getting the value of a key
--------------------------

[](#getting-the-value-of-a-key)

There are two flavors of methods for getting a configuration value:

- Mandatory keys (man for short). These methods will never return a null value.
- Optional keys (opt for short). These methods will return null if the key does not exists or has value `null`.

All methods will try to cast the value of a key to the required type using package [setbased/helper-cast](https://github.com/SetBased/php-helper-cast/blob/master/composer.json). I.e. if the value of key is `string(1)` method `getManBool` will return `bool(true)` and method `getManInt` will return `int(1)`.

All methods have two arguments:

1. The key.
2. An optional default value. this value will be returned if the key does not exists or has value `null`.

The table below gives an overview of all methods for getting the value of a key.

MethodNull ValueReturn TypegetManArraythrows an exceptionarraygetManBoolthrows an exceptionboolgetManFiniteFloatthrows an exceptionfloatgetManFloatthrows an exceptionfloatgetManIntthrows an exceptionintgetManStringthrows an exceptionstringgetOptArrayreturns nullarray|nullgetOptBoolreturns nullbool|nullgetOptFiniteFloatreturns nullfloat|nullgetOptFloatreturns nullfloat|nullgetOptIntreturns nullint|nullgetOptStringreturns nullstring|nullInstallation
============

[](#installation)

Strong Typed Config can be installed using composer:

```
composer require setbased/typed-config
```

License
=======

[](#license)

This project is licensed under the terms of the MIT license.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance47

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity77

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

Total

5

Last Release

390d ago

Major Versions

1.2.0 → 2.0.02023-01-26

PHP version history (4 changes)1.0.0PHP &gt;=7.1.0

1.2.0PHP &gt;=7.4

2.0.0PHP &gt;=8.1

2.1.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/67edc824131704a5270570c8bba7fc52986f3e70a0389aca6b13ea87ca4d9710?d=identicon)[Paul Water](/maintainers/Paul%20Water)

---

Top Contributors

[![prwater](https://avatars.githubusercontent.com/u/17372665?v=4)](https://github.com/prwater "prwater (19 commits)")

---

Tags

jsonconfigurationxmlconfigyamlymlinistrong typed

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/setbased-typed-config/health.svg)

```
[![Health](https://phpackages.com/badges/setbased-typed-config/health.svg)](https://phpackages.com/packages/setbased-typed-config)
```

###  Alternatives

[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

1.0k13.8M187](/packages/hassankhan-config)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.3k1](/packages/m1-vars)[thewunder/conphigure

Framework Agnostic Configuration Library

3120.6k](/packages/thewunder-conphigure)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

359.2k1](/packages/davidepastore-slim-config)

PHPackages © 2026

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