PHP code example of oleics / ac-config

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

    

oleics / ac-config example snippets




use Ac\Config\Config;

$config = Config::loadFromYaml('config.yaml');

echo $config->env->mode;      // > development
echo $config->fooBar;         // > baz

// Converts to JSON
echo $config->env.'';         // > {"mode":"development"}
echo Config::toJson($config); // > {"env":{"mode":"development"},"foo-bar":"baz"}

// Next line throws an exception
$config->env = 'production';



use Ac\Config\Env;

// maybe boot-level *hinthint*
Env::loadConfigFromYaml('config.yaml');
Env::autoset(); // throws if no valid env-mode could be detected

// maybe app-level *hinthint*
Env::configDefaults([
  'foo' => 'bar'
]);

// maybe controller-level *hinthint*
echo Env::$config->env->mode === Env::getMode(); // > true

if(Env::isNotProduction()) {
  // Something to print for non-production environments (development or staging)
  echo Env::$config->foo;    // > bar
  echo Env::$config->fooBar; // > baz
}