PHPackages                             devly/config-loader - 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. devly/config-loader

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

devly/config-loader
===================

Load configurations from multiple sources into a `Devly\\Repository` object.

1.0.1(2y ago)06311PHPPHP &gt;=7.4

Since Jul 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/valenjeb/config-loader)[ Packagist](https://packagist.org/packages/devly/config-loader)[ RSS](/packages/devly-config-loader/feed)WikiDiscussions master Synced today

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

Configuration Loader
====================

[](#configuration-loader)

Load configurations from multiple sources into a [Repository](https://github.com/valenjeb/repository) object. Supported file formats are: PHP, JSON, INI, XML, Yaml &amp; Neon.

Install
=======

[](#install)

Install using `composer`:

```
$ composer require devly/config-loader
```

Usage
-----

[](#usage)

### Create Loader object

[](#create-loader-object)

```
$safeMode = false // Set 'true' to skip exceptions

$loader = new \Devly\ConfigLoader\Loader($safeMode);
```

### Load configurations from file

[](#load-configurations-from-file)

```
// Load config from a single file
$config = $loader->load('path/to/config.php');

// Load config from a list of files
$segment = true; // Segment configuration by file name

$files = [
    'path/to/config/app.php',
    'path/to/config/database.php',
];

$config = $loader->load($files, $segment);

var_dump($config->all());

// array(1) {
//  'app' => ...,
//  'database' => ...
// }
```

### Load configuration files from a directory

[](#load-configuration-files-from-a-directory)

```
// Load config from a single file
$formats = ['php', 'json']; // load only php and json files. keep null to load all the files in the directory
$segment = true; // Segment configuration by file names
$config = $loader->load('path/to/config', $segment, $formats);
```

### Cache configurations

[](#cache-configurations)

Configurations can be cached to a file, a MySQL database or a custom storage provider.

#### Cache to file

[](#cache-to-file)

The only thing needed to cache configurations to file is to set a full path to cache directory:

```
// When creating new Loader instance
$loader = new Loader($safeMode, 'full/path/to/cache');

// Or using the `setStorage()` method:
$loader->setStorage('full/path/to/cache');
```

#### Cache to MySQL database

[](#cache-to-mysql-database)

```
$name = 'db_name';
$username = 'db_user';
$password = 'db_password';
$host = '172.0.0.1'; // Default 'localhost'

// Create instance of DatabaseStorage
$storage = new \Devly\ConfigLoader\Storages\DatabaseStorage($name, $username, $password, $host)

// Creating new Loader instance
$loader = new Loader($safeMode, $storage);

// Or using the `setStorage()` method:
$loader->setStorage($storage);
```

#### Custom cache storage

[](#custom-cache-storage)

```
class CustomStorage implements \Devly\ConfigLoader\Contracts\IStorage
{
    ...
}

$storage = new CustomStorage();

// Creating new Loader instance
$loader = new Loader($safeMode, $storage);

// Or using the `setStorage()` method:
$loader->setStorage($storage);
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

883d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.0.1PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devly-config-loader/health.svg)

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

PHPackages © 2026

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