PHP code example of hail / config

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

    

hail / config example snippets



return [
    'key' => [
        'sub' => true
    ],
];


use Hail\Config\Env

$env = new Env(__DIR__);
$env->get('ENVIRONMENT');

use Hail\Config\Config;

$cachePath = __DIR__ . DIRECTORY_SEPARATOR . 'cache';
$options = [
    'path' => __DIR__, // same as 'path' => ['env' => __DIR__, 'config' => __DIR__ . DIRECTORY_SEPARATOR . 'config'],
    'loaders' => [  // if empty, the default loader is Hail\Config\Loader\Php 
        Config::loader('yaml', $cachePath),
        Config::loader('json', $cachePath)
    ]
];
$config = new Config(...$options);

$config->addLoader(
    new Hail\Config\Loader\Php()
);

$config->get('filename.key.sub');

$env->get('ENVIRONMENT') === $config->env('ENVIRONMENT'); //true
$config->env->get('ENVIRONMENT') === $config->env('ENVIRONMENT'); //true
$config->env === $config->env(); //true