PHP code example of theiconic / config

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

    

theiconic / config example snippets


// get the factory instance
$factory = Factory::getInstance();

// set the current environment
$factory->setEnvironment(APPLICATION_ENV);

// configure cache path
$factory->setCachePath(sprintf('%s/config', APPLICATION_TMP));

// instanciate and configure the application config space
$factory->getSpace('application')
    ->setPaths([
        '/etc/iconic.ini',
        $basePath . 'application.ini',
        $basePath . 'application.local.ini',
    ])
    ->setSections([
        'default',
        'production',
    ])
    ->setPlaceholders([
        '%APPLICATION_ENV%' => APPLICATION_ENV,
        '%APPLICATION_ROOT%' => APPLICATION_ROOT,
        '%APPLICATION_TMP%' => APPLICATION_TMP,
    ]);


$space = Factory::getInstance()->getSpace('application');
foreach ($_ENV as $key => $value) {
    $placeholder = sprintf('%%ENV_%s%%', strtoupper(str_replace('%', '_', $key)));
    $space->addPlaceholder($placeholder, $value);
}