PHP code example of werx / config

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

    

werx / config example snippets


# Get an instance of the ArrayProvider
$provider = new \werx\Config\Providers\ArrayProvider('/path/to/config/directory');

# Create a Config\Container Instance from this provider.
$config = new \werx\Config\Container($provider);

# Load config/config.php
$config->load('config');

# Get an item.
$item = $config->get('foo');

$config = new \werx\Config\Container($provider);
$config->load('config');


$item = $config->get('foo');

print $item;
// Foo

$item = $config->get('doesnotexist', false);
var_dump($item);
// false;

$config->setEnvironment('test');
$config->load('config');

$config->load(['config', 'another_config']);

$config->load(['config', 'email'], true);

config/
    config.php
    another_config.php
    /local/
        config.php
    /test/
        config.php
    /prod/
        config.php
 php

return [
	'foo' => 'Foo',
	'bar' => 'Bar'
];
 php
$provider = new \werx\Config\Provider\ArrayProvider('/path/to/config/directory');
 php
$provider = new \werx\Config\Provider\JsonProvider('/path/to/config/directory');