PHPackages                             mkomorowski/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. mkomorowski/php-config

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

mkomorowski/php-config
======================

Simple class supporting different configuration values based on the environment

1.0(10y ago)1183MITPHPPHP &gt;=5.3.0

Since Jun 14Pushed 10y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

php-config
==========

[](#php-config)

[![Latest Stable Version](https://camo.githubusercontent.com/5e8681702991e59fc97ed3f1818bb95ae6ed80373d36808b535a344f51566b33/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6f6d6f726f77736b692f7068702d636f6e6669672f762f737461626c65)](https://packagist.org/packages/mkomorowski/php-config)[![Build Status](https://camo.githubusercontent.com/481b6eb111633fa63bf3a6ef8d30497764abc13034cf3d00b99434d243e1d28a/68747470733a2f2f7472617669732d63692e6f72672f6d4b6f6d6f726f77736b692f7068702d636f6e6669672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mKomorowski/php-config)[![Coverage Status](https://camo.githubusercontent.com/bf031f201f052f8928cd4057792d604a85425504f1ee64d46cc7014f94b4710d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d4b6f6d6f726f77736b692f7068702d636f6e6669672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/mKomorowski/php-config?branch=master)

A simple class supporting different configuration values based on the environment

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

[](#installation)

The package can be installed via Composer by adding to the `composer.json` require block.

```
{
    "require": {
        "mkomorowski/php-config": "1.0"
    }
}
```

Then update application packages by running the command:

```
php composer.phar update
```

Configuration
-------------

[](#configuration)

Examples of files with application configuration options.

local.php

```
return array(
        'debug' => true,
        'database' => array(
            'host' => '127.0.0.1',
            'password' => 'password',
        ),
);
```

production.php

```
return array(
        'debug' => false,
        'database' => array(
            'host' => 'rds.amazon.com',
            'password' => 'password',
        ),
);
```

In the settings loader we are specifying the path to the directory with config files.

```
$loader = new mKomorowski\Config\Loader('/app/config');
```

Next we are defining the environment settings:

```
$environment = new mKomorowski\Config\Environments(array(
    'local' => array('local', 'MacBook.local'),
    'stage' => array('cent_os_stage')
));
```

Finally we initialize the Config class, passing settings and environments. The third paramater is an optional default environment.

```
$config = new mKomorowski\Config\Config($loader, $environment, 'stage');
```

We can change the default environment later by:

```
$config->setDefaultEnvironment('production');
```

Usage
-----

[](#usage)

To retrieve the settings just use:

```
$config->get('debug');
```

Accessing nested values is possible with dotted notation

```
$config->get('database.hostname');
```

If your hosts is signed to a specific environment it will return the appropriate value. If not it will look for default environment settings or return `null` if the key is not set.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3991d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2849985c2d774ba1cfcd3d6cdab6a63ed99fd1325b1ff8d2d21dbaaa6a9cd283?d=identicon)[mKomorowski](/maintainers/mKomorowski)

---

Top Contributors

[![mKomorowski](https://avatars.githubusercontent.com/u/4342800?v=4)](https://github.com/mKomorowski "mKomorowski (16 commits)")

---

Tags

phpSettingsconfigenvironmenthosts

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[akaunting/laravel-setting

Persistent settings package for Laravel

495805.1k7](/packages/akaunting-laravel-setting)

PHPackages © 2026

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