PHPackages                             jamesgober/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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. jamesgober/config

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

jamesgober/config
=================

Advanced PHP configuration management designed for flexibility and performance, with built-in support for JSON, YAML, XML, INI, and limitless custom formats.

v1.0.0(1y ago)248↓100%MITPHPPHP &gt;=8.2

Since Nov 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jamesgober/Config)[ Packagist](https://packagist.org/packages/jamesgober/config)[ Docs](https://github.com/jamesgober/Config)[ RSS](/packages/jamesgober-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (7)Used By (0)

   ![Official brand mark and logo of James Gober. Image shows JG stylish initials encased in a hexagon outline.](./docs/media/jamesgober-logo.png)
 **CONFIG MANAGER**
 BY JAMES GOBER

===========================================================================================================================================================================================

[](#--------------------------------config-manager--------by-james-gober----)

 [![GitHub Stars](https://camo.githubusercontent.com/7ff22ce1b4fcaa4adde9e3a0d819d9cd5f4204b560a297c28827d6c45724867b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174)](https://camo.githubusercontent.com/7ff22ce1b4fcaa4adde9e3a0d819d9cd5f4204b560a297c28827d6c45724867b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174) [![GitHub Issues](https://camo.githubusercontent.com/ad956194df1634d3e3c3dc23232f0d4b05f0906a27d9c87c5abba222bd2fce36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174)](https://camo.githubusercontent.com/ad956194df1634d3e3c3dc23232f0d4b05f0906a27d9c87c5abba222bd2fce36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174) [![GitHub Release](https://camo.githubusercontent.com/7c5ad4e728da14d427b5bc876053d81b3607049399f99443b11dfb8593276ec9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a616d6573676f6265722f636f6e6669673f646973706c61795f6e616d653d746167267374796c653d666c6174)](https://camo.githubusercontent.com/7c5ad4e728da14d427b5bc876053d81b3607049399f99443b11dfb8593276ec9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a616d6573676f6265722f636f6e6669673f646973706c61795f6e616d653d746167267374796c653d666c6174) [![GitHub License](https://camo.githubusercontent.com/cb156ecf3e4b4395a92db85c7fd24b26aaee2adc93638317cba87d558b84d9ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174)](https://camo.githubusercontent.com/cb156ecf3e4b4395a92db85c7fd24b26aaee2adc93638317cba87d558b84d9ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a616d6573676f6265722f636f6e6669673f7374796c653d666c6174) [![PHP Version](https://camo.githubusercontent.com/b9d936ad3cc55dae0242b76220d637004127271d9859f9ce6ed5ab231229aac9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d626c75653f7374796c653d666c6174)](https://camo.githubusercontent.com/b9d936ad3cc55dae0242b76220d637004127271d9859f9ce6ed5ab231229aac9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d626c75653f7374796c653d666c6174) [ ![Packagist Downloads](https://camo.githubusercontent.com/ebabe4181d06777de9cfa258212a682e2bb14e2a47c6ce85ce44507891d47d5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616d6573676f6265722f636f6e6669673f7374796c653d666c617426636f6c6f723d253233663236663161) ](https://packagist.org/packages/jamesgober/config)

A Flexible PHP Configuration Manager
------------------------------------

[](#a-flexible-php-configuration-manager)

Config is a lightweight yet powerful PHP library designed to handle your application's configuration needs with ease and efficiency. Supporting multiple formats like **JSON**, **XML**, **YAML**, **INI**, and **PHP** arrays out of the box, it provides the flexibility to add custom parsers tailored to your specific requirements. With robust error handling, performance-focused design, and a modular architecture, **JG\\Config** simplifies configuration management for modern PHP projects.

Key Features
------------

[](#key-features)

- **Multi-Format Support**: Seamlessly load configurations from **JSON**, **XML**, **YAML**, **INI**, **PHP**, and **CONF** files.
- **Custom Parsers**: Extend functionality by adding support for any file format with ease.
- **Performance Optimizations**: Designed for speed, even with large or deeply nested configurations.
- **Advanced Features**: Includes caching, dynamic flattening control, and stream parsing for modern workflows.
- **Robust Error Handling**: Custom exceptions provide clear and actionable feedback for debugging.
- **Lightweight and Intuitive**: A simple yet powerful API designed for minimal overhead and ease of use.

Why Choose This Library?
------------------------

[](#why-choose-this-library)

**JG\\Config** is built for developers who demand efficiency, reliability, and flexibility in their projects:

- **High Performance**: Optimized for speed with low overhead, making it ideal for high-load scenarios.
- **Modular Design**: Extend or replace parsers effortlessly to meet custom needs.
- **Error-Resilient**: Provides comprehensive error handling with meaningful exception messages.
- **Extensively Tested**: Rigorously tested with PHPUnit for predictable and stable performance.
- **Built on Principles**: Adheres to S.O.L.I.D design principles and emphasizes maintainability and extensibility.

Whether you're building a small application or managing a large-scale project, **JG\\Config** provides a robust solution to streamline your configuration management.

---

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

[](#installation)

Install via [composer](https://getcomposer.org/download/):

```
$ composer require jamesgober/config
```

Quick Start
-----------

[](#quick-start)

#### Load Configurations

[](#load-configurations)

Effortlessly load multiple configuration files in various formats:

```
use JG\Config\Config;

$config = new Config('/path/to/config/files');

// Load files
$config->load('database.json');
$config->load('app.xml');

// Access values
$dbHost = $config->get('database.host', 'default_host');

// Check keys
if ($config->has('app.debug')) {
    echo "Debug mode is enabled!";
}

// Add or update values
$config->add('app.name', 'MyApp');
```

#### Manage Configurations

[](#manage-configurations)

Easily delete individual values or entire groups:

```
// Delete specific values
$config->delete('app.version'); // Removes app.version

// Delete groups
$config->delete('app'); // Removes app.name, app.debug, etc.
```

#### Extend with Custom Parsers

[](#extend-with-custom-parsers)

Add support for new file formats via custom parsers:

```
use JG\Config\ConfigParserFactory;

// Register a parser for .custom files
ConfigParserFactory::registerParser('custom', MyCustomParser::class);
```

---

Supported Formats
-----------------

[](#supported-formats)

**Format****Example****Extension**CONF`config.conf``.conf`INI`config.ini``.ini`JSON`config.json``.json`PHP Array`config.php``.php`XML`config.xml``.xml`YAML`config.yaml``.yaml`, `.yml`For more examples, see our **[Advanced Usage](docs/ADVANCED.md)** guide.

---

Error Handling
--------------

[](#error-handling)

### Custom Exceptions

[](#custom-exceptions)

JG\\Config uses custom exceptions for intuitive error handling:

**Exception****Description**`ConfigException`General errors related to configuration.`ConfigParseException`Errors when parsing configuration files.`InvalidParserException`When unsupported or invalid parsers are used.**Example Usage:**

```
use JG\Config\Exceptions\ConfigException;

try {
    $config->load('missing_file.json');
} catch (ConfigException $e) {
    echo "Error: " . $e->getMessage();
}
```

---

Advanced Features
-----------------

[](#advanced-features)

Explore advanced capabilities like caching, custom parsers, and dynamic flattening in our **[Advanced Guide](docs/ADVANCED.md)**.

---

Directory Structure
-------------------

[](#directory-structure)

```
src/
├── Config.php                  # Core configuration management class
├── ConfigParserFactory.php     # Factory for parser resolution
├── Exceptions/                 # Custom exceptions for robust error handling
│   ├── ConfigException.php
│   ├── ConfigParseException.php
│   └── InvalidParserException.php
├── Parsers/                    # Built-in parsers for supported formats
│   ├── ParserInterface.php
│   ├── PhpParser.php
│   ├── JsonParser.php
│   ├── IniParser.php
│   ├── XmlParser.php
│   └── YamlParser.php
tests/                          # Unit and integration tests

```

---

Reporting Security Issues
-------------------------

[](#reporting-security-issues)

We take security seriously. If you find a vulnerability, please consult our **[SECURITY POLICY](.github/SECURITY.md)** and follow the instructions for reporting.

Do not use public issue trackers or forums to disclose sensitive information.

---

Reporting Bugs and Feature Requests
-----------------------------------

[](#reporting-bugs-and-feature-requests)

For non-security issues, such as bugs or feature requests, please use our **[Issue Tracker](https://github.com/jamesgober/Config/issues)**. Providing detailed information will help us resolve issues efficiently.

---

Design Philosophy
-----------------

[](#design-philosophy)

Learn about the principles that guide the development of **JG\\Config** in our **[Design Philosophy](docs/DESIGN_PHILOSOPHY.md)**.

---

Contributing
------------

[](#contributing)

Contributions are welcome! Check out the **[Contribution Guidelines](.github/CONTRIBUTING.md)** and review our **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** for more information.

---

License
-------

[](#license)

This library is open-source software licensed under the [MIT license](LICENSE).

 [↑
 TOP ](#top)

 COPYRIGHT © 2024 JAMES GOBER &amp; JAMESGOBER.COM.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

6

Last Release

520d ago

PHP version history (2 changes)v1.0.0-Rc.1PHP &gt;=8.2

v1.0.0-RC.2PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![jamesgober](https://avatars.githubusercontent.com/u/12473969?v=4)](https://github.com/jamesgober "jamesgober (82 commits)")

---

Tags

configconfigurationconfiguration-managementextensibleini-parserjson-parserphpxml-parseryaml-parserpsrphpjsonconfigurationSettingsxmlconfigparseryamlloadersettings managementconfiguration manager

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[hassankhan/config

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

97513.5M169](/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.2k1](/packages/m1-vars)[davidepastore/slim-config

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

338.9k1](/packages/davidepastore-slim-config)[thewunder/conphigure

Framework Agnostic Configuration Library

3115.9k](/packages/thewunder-conphigure)

PHPackages © 2026

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