PHP code example of donsimon / alt-brite-config

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

    

donsimon / alt-brite-config example snippets




$config['default']['database']['host'] = 'bar';
$config['default']['database']['user'] = 'foo';
$config['default']['database']['pass'] = 'baz';

$config['default']['service']['api_key'] = '123456';
$config['default']['email'] = '[email protected]';

$config['production']['extends'] = 'staging';
$config['production']['database']['user'] = 'foo1';
$config['production']['database']['pass'] = 'baz1';
$config['production']['email'] = '[email protected]';

$config['staging']['extends'] = 'default';
$config['staging']['database']['user'] = 'foo2';
$config['staging']['database']['pass'] = 'baz2';



use Brite\Config\Config;

// Registering as the 'default' config means you can grab the config
// without specifying a name.
Config::register('default', __DIR__ . '/test_config/config.php', 'staging');



use Brite\Config\Config;

// This grabs the config registered as 'default'
$config = Config::instance();

echo $config->get('database.host');
// output: "bar"
echo $config->get('database.user');
// output: "foo1"



use Brite\Config\Config;

// This grabs the config registered as 'database'
$dbConfig = Config::instance('database');

echo $dbConfig->get('host');
echo $dbConfig->get('user');



use Brite\Config\IniConfig;

$config = new IniConfig('/path/to/file.ini', 'staging');

// Now register $config with your registry