PHP code example of comphp / config

1. Go to this page and download the library: Download comphp/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/ */

    

comphp / config example snippets


use Neuron\Configuration\ConfigManager;
use DI\ContainerBuilder;

$container = (new ContainerBuilder())->build();
$configManager = new ConfigManager($container);

$configManager->load('database', 'config.json');
$configManager->load('app', 'config.php');

echo $configManager->get('database.host', 'default_host');

$configManager->set('cache.enabled', true);
$configManager->unset('cache.enabled');

print_r($configManager->toArray());

use Neuron\Configuration\Parsers\JsonParser;
use Neuron\Configuration\ParserRegistry;

$parserRegistry = $configManager->parsers;
$parserRegistry->register(YamlParser::class, 'yaml');
$parserRegistry->register(DatabaseParser::class, 'db')

use Neuron\Configuration\MergeMode;
$configManager->load('app', 'config.json', MergeMode::Merge);