Configuration handler class.

v0.2.1 2015-02-27 12:20 UTC

This package is not auto-updated.

Last update: 2024-07-16 01:46:15 UTC


README

A little configuration class for PHP 5.4+.

Work In Progress. You have been warned.

Installation and use

Using composer:

$ composer require allmarkedup/conph

Example

<?php

class MyConfig extends Amu\Conph\Config
{
    public function convertPaths($value)
    {
        return array_map(function($item){
            return '/my/base/path' . $item;
        }, $value);
    }
}

$config = new MyConfig([
    "paths" => [
        "templates" => "the_template_path",
        "config" => "the_config_path"
    ],
    "settings" => [
        "debug" => true
    ],
    'names' => [
        "batman" => 'Fred',
        "superman" => 'Dave'
    ]
]);

// Nested values - dot notation
$debug = $config->get('settings.debug');
$config->set('names.batman', 'Clive');

// Custom converter functions
$config->get('paths.templates'); // => /my/base/path/the_template_path