Download the PHP package andym84/config without Composer
On this page you can find all versions of the php package andym84/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andym84/config
More information about andym84/config
Files in andym84/config
Package config
Short Description Configuration Management
License MIT
Homepage https://github.com/AndyM84/config-migration
Informations about the package config
config-migration
A simple (but effective!) system for managing different versions of configuration files and their settings.
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:
Installation
As with most things, I've made this available via Composer, you can add "andym84/config": "^1.0"
to your composer.json
or you can simply execute the command:
Alternatively, of course, you're welcome to simply download the source code and reference it manually.
Usage
Usage of the system requires at least two things:
- A script that executes the
Migrator
- 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:
Consider the following two instruction files in your cfgMigrations
directory, 0-1.cfg
and 1-2.cfg
.
cfgMigrations/0-1.cfg
cfgMigrations/1-2.cfg
If you run these through a migration, the system will produce the following siteSettings.json
file:
Config Migrations
Each config migration is a file with simple per-line instructions. The file name is in the format <VERSION1>-<VERSION2>.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:
Valid field types:
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:
Finally, an example migration script, 3-4.cfg
, which migrates the config file from version 3 to 4:
This file will perform the following actions, in order:
- Add
someVersion
string property with value1.1.2
- Add
ownerName
string property with valueAndrew Male
- Remove
ownerFirstName
property - Rename
ownerLastName
property toownerSurname
- Set
configVersion
integer property to4
based on the file name