PHPackages                             formigone/php-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. formigone/php-config

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

formigone/php-config
====================

v0.0.1(9y ago)019PHP

Since Oct 8Pushed 9y agoCompare

[ Source](https://github.com/formigone/php-config)[ Packagist](https://packagist.org/packages/formigone/php-config)[ RSS](/packages/formigone-php-config/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP-CONFIG
==========

[](#php-config)

This project is a loose port of [node-config](https://www.npmjs.com/package/config). I've only implemented enough of it to help me get going with an existing project.

### What does it do?

[](#what-does-it-do)

The goal of this package is to help you manage configuration files separated by environment, but used as a single object.

### How it works

[](#how-it-works)

Suppose your application exists in three environments: `development`, `stage`, and `production`. Each environment has its own unique configurations, and all three share some configuration in common.

As an organized developer, you'll create a `config` directory somewhere in your project, where you'll store the following files:

```
/project
  /config
     default.json
     development.json
     stage.json
     production.json

// config/default.json
{
  "appVersion": "1.0.0",
  "app": {
    "views": {
      "cache": false
    }
  }
}

// config/development.json
{
  "db": {
    "username": "root",
    "password": "",
    "host": "localhost"
  }
}

// config/default.json
{
  "db": {
    "username": "stage-user",
    "password": "stage-password",
    "host": "stage-db"
  }
}

// config/default.json
{
  "db": {
    "username": "secure-user",
    "password": "secure-password",
    "host": "super-cluster"
  },
  "app": {
    "views": {
      "cache": true
    }
  }
}
```

You'll then have a single config object for whatever environment you're in, where `default.json` and the environment-specific `.json` object are merged together, with the default values being overwritten by the environment values (using a shallow merge).

```
$env = getenv('APP_ENV');
$configPath = __DIR__ . '/config';

$config = new Formigone\Config($env, $configPath);

$appVersion = $config->get('appVersion');
$db = $config->get('db');
$shouldCacheViews = $config->get('app.views.cache');
```

### Why reinvent the wheel?

[](#why-reinvent-the-wheel)

So this project essentially mimics [ZF1's Zend\_Config](https://github.com/zf1/zend-config), which allows for inheritable configs. Why use this instead?

- Why use JSON?
    - So configs can be shared across PHP and JavaScript/Node.js
- Why not use Zend\_Config\_Json?
    - Because Zend\_Config\_Json only parses a single file. That works fine in PHP, but if you use something in Node.js like node-config (which is what I happen to use), the you can't reuse the same config files. Given my specific use case (where I'm reusing configs and starting off with node-config), this makes sense, and hence my need for this package.

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

3599d ago

### Community

Maintainers

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

---

Top Contributors

[![formigone](https://avatars.githubusercontent.com/u/852234?v=4)](https://github.com/formigone "formigone (7 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/runtime

Enables decoupling PHP applications from global state

740103.0M1.2k](/packages/symfony-runtime)[shalvah/upgrader

Create automatic upgrades for your package.

1513.6M9](/packages/shalvah-upgrader)

PHPackages © 2026

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