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

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

philiprehberger/php-config-loader
=================================

Load configuration from JSON and PHP files with environment variable substitution

v1.0.3(today)11MITPHPPHP ^8.2CI passing

Since Mar 13Pushed todayCompare

[ Source](https://github.com/philiprehberger/php-config-loader)[ Packagist](https://packagist.org/packages/philiprehberger/php-config-loader)[ Docs](https://github.com/philiprehberger/php-config-loader)[ RSS](/packages/philiprehberger-php-config-loader/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (5)Used By (0)

PHP Config Loader
=================

[](#php-config-loader)

[![Tests](https://github.com/philiprehberger/php-config-loader/actions/workflows/tests.yml/badge.svg)](https://github.com/philiprehberger/php-config-loader/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/561a2bacdea9995f0c582052cf054e159561ea4ac81f3a63196b7eff01e19d2b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068696c69707265686265726765722f7068702d636f6e6669672d6c6f616465722e737667)](https://packagist.org/packages/philiprehberger/php-config-loader)[![License](https://camo.githubusercontent.com/7662c7bf66cab33e0f3fa941be62c1f6408615a1faed041bcfcc84b0f6034b98/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068696c69707265686265726765722f7068702d636f6e6669672d6c6f61646572)](LICENSE)

Load configuration from JSON and PHP files with environment variable substitution.

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

[](#requirements)

- PHP 8.2+

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

[](#installation)

```
composer require philiprehberger/php-config-loader
```

Usage
-----

[](#usage)

### Loading a Single File

[](#loading-a-single-file)

```
use PhilipRehberger\ConfigLoader\ConfigLoader;

// Load a PHP config file
$config = ConfigLoader::load(__DIR__ . '/config/app.php');

// Load a JSON config file
$config = ConfigLoader::load(__DIR__ . '/config/database.json');
```

**PHP config file** (`app.php`):

```
