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

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

andym84/config
==============

Configuration Management

1.4.0(8mo ago)02.8k—0%2MITPHPPHP &gt;=8.3

Since Oct 12Pushed 8mo agoCompare

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

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

config-migration
================

[](#config-migration)

A simple (but effective!) system for managing different versions of configuration files and their settings.

[![Build Status](https://camo.githubusercontent.com/4e5a4f95a7e5c9ffbc9884f152ae40c092aab309ff23a4c7625c392402f25654/68747470733a2f2f7472617669732d63692e636f6d2f416e64794d38342f636f6e6669672d6d6967726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/AndyM84/config-migration)

Development Setup
-----------------

[](#development-setup)

There are no dependencies other than PHP (of course) to use the system, however if you'd like to use the source code and run the tests, feel free to clone or download the repo and run the following commands from the repository root:

```
composer update
vendor/bin/phpunit -c phpunit.xml ./Tests
```

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

[](#installation)

As with most things, I've made this available via [Composer](https://packagist.org/packages/andym84/config), you can add `"andym84/config": "^1.0"` to your `composer.json` or you can simply execute the command:

```
composer require andym84/config

```

Alternatively, of course, you're welcome to simply download the source code and reference it manually.

Usage
-----

[](#usage)

Usage of the system requires at least two things:

1. A script that executes the `Migrator`
2. A folder that contains one or more instruction files

Assuming you'll use a directory called `cfgMigrations` for your instruction files, your usage may be as simple as this:

```
require('vendor/autoload.php');

use AndyM84\Config\ConfigContainer;
use AndyM84\Config\Migrator;

// Perform any required migrations
$migrator = new Migrator('cfgMigrations');
$migrator->migrate();

// Consume the config file for easy use
$cfg = new ConfigContainer(file_get_contents('siteSettings.json'));

echo($cfg->get('configVersion')); // Echos whatever version your configs are at after migration
```

Consider the following two instruction files in your `cfgMigrations` directory, `0-1.cfg` and `1-2.cfg`.

#### cfgMigrations/0-1.cfg

[](#cfgmigrations0-1cfg)

```
siteVersion[str] + 1.0.0
siteTitle[str] + Default Title

```

#### cfgMigrations/1-2.cfg

[](#cfgmigrations1-2cfg)

```
siteTitle > frontTitle
backTitle[str] + Default Backend Title
smtp.host[str] + localhost
smtp.port[int] + 25
corsOrigins[str[]] + http://localhost
corsOrigins[str[]] + https://mydomain.com

```

If you run these through a migration, the system will produce the following `siteSettings.json` file:

```
{
    "schema": {
        "configVersion": "int",
        "siteVersion": "str",
        "frontTitle": "str",
        "backTitle": "str",
        "smtp.host": "str",
        "smtp.port": "int",
        "corsOrigins": "str[]"
    },
    "settings": {
        "configVersion": 2,
        "siteVersion": "1.0.0",
        "frontTitle": "Default Title",
        "backTitle": "Default Backend Title",
        "smtp": {
          "host": "localhost",
          "port": 25
        },
        "corsOrigins": [
          "http://localhost",
          "https://mydomain.com"
        ]
    }
}
```

Config Migrations
-----------------

[](#config-migrations)

Each config migration is a file with simple per-line instructions. The file name is in the format `-.cfg`, which allows the system to know which version it should look to migrate from and to. Instructions contain 2-3 segments:

```
 [ ]

```

The first two segments are required, and the third (`value`) is optional depending on the operator being used. The following operators are available:

```
+ Add field w/ value
> Rename field
= Change field value
- Remove field

```

Valid field types:

```
int Integer
flt Float
str String
bln Boolean
int[] Array of Integers
flt[] Array of Floats
str[] Array of Strings
bln[] Array of Booleans

```

The array types can be added, renamed, or removed from migration files, but cannot be changed.

Finally, when used, the `value` segment can contain any character (excluding the newline), as well as these special values:

```
""          Empty string
${propName} Interpolates the value of an existing property (will not be replaced if the property doesn't exist)

```

Finally, an example migration script, `3-4.cfg`, which migrates the config file from version 3 to 4:

```
someVersion[str] + 1.1.2
ownerName[str] + Andrew Male
ownerFirstName -
ownerLastName > ownerSurname

```

This file will perform the following actions, in order:

- Add `someVersion` string property with value `1.1.2`
- Add `ownerName` string property with value `Andrew Male`
- Remove `ownerFirstName` property
- Rename `ownerLastName` property to `ownerSurname`
- Set `configVersion` integer property to `4` based on the file name

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

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

Recently: every ~292 days

Total

7

Last Release

253d ago

PHP version history (6 changes)1.0.0PHP ^7

1.0.1PHP &gt;=7.4

1.1.0PHP &gt;=8

1.1.1PHP &gt;=8.1

1.2.0PHP &gt;=8.2

1.3.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b97080c09e519ff3a9d88589fd9780094fd2381c7af106ff6b3b017d1c6c6d1?d=identicon)[AndyM84](/maintainers/AndyM84)

---

Top Contributors

[![AndyM84](https://avatars.githubusercontent.com/u/1574682?v=4)](https://github.com/AndyM84 "AndyM84 (20 commits)")

---

Tags

configurationautomationconfig

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[dflydev/dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

13414.5M4](/packages/dflydev-dot-access-configuration)[dmishh/settings-bundle

Database centric Symfony configuration management. Global and per-user settings supported.

115254.9k1](/packages/dmishh-settings-bundle)[caseyamcl/configula

A simple, but versatile, PHP config loader

42146.6k6](/packages/caseyamcl-configula)[illuminatech/array-factory

Allows DI aware object creation from array definition

2159.6k5](/packages/illuminatech-array-factory)

PHPackages © 2026

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