PHP code example of myerscode / config

1. Go to this page and download the library: Download myerscode/config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

myerscode / config example snippets


$config = new Config();

$config->loadFiles([
'config/app.php',
'config/db.yaml',
]);

$config->loadFile('config/cache.php');

$config->loadData(['api_key' => 'abc123']);

// example config object
[
    'name' => 'myerscode',
    'db_name' => 'myerscode_db',
    'api_key' => 'abc123',
]

$config = new Config();

$config->loadFilesWithNamespace([
'config/app.php',
'config/db.yaml',
]);

$config->loadFileWithNamespace('config/cache.php');

// example config object
[
    'app' => [...],
    'db' => [...],
    'cache' => [...],
]

$config->value('app.name');

$config->value('app');

$config->value('api_key');

$config->values();

$store = $config->store();

// app.config.php
return [
    'name' => 'Fred Myerscough',
    'settings' => [
        'a',
        'b',
        'c'
    ],
];
 
// app.config.php
return [
    'name' => 'myerscode',
    'env' => 'myerscode',
];

// db.config.php
return [
    'db' => [
        'setting' => [
            'name' => '${env}_${name}_db',
        ]
    ],
    'db_name' => '${db.config.name}'
];