rogerthomas84/php-config-dot-notation

Interact with config using a dot notation

1.0.1 2021-02-05 13:31 UTC

This package is auto-updated.

Last update: 2024-12-13 15:22:41 UTC


README

Get and set config from an array using a dot notation.

Usage:

Create the config:

<?php
$config = [
    'app' => [
        'name' => 'Foo Bar',
        'version' => 1
    ]
];
\ConfigDot\Config::setConfig($config);

Get a value:

<?php
// set the config as above

$appName = \ConfigDot\Config::get('app.name');
// $appName = string(7) "Foo Bar" (or null if it does not exist)

Check if a value exists:

<?php
// set the config as above

if (\ConfigDot\Config::has('app.name')) {
    // it does!
}

Set a new config value:

Setting a new config value doesn't eliminate the original value, but the order of priority will dictate that the new value will be returned from a get request.

<?php
// set the config as above

\ConfigDot\Config::update('app.name', 'Wolf');