1. Go to this page and download the library: Download beatlabs/load 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/ */
$loader = new BeatLabs\Load\Loader\PHPLoader('config.php'); // Config file
$config = new BeatLabs\Load\Config([$loader]);
$config->load();
// Get configuration values
$val = $config->get('var');
$loader = new BeatLabs\Load\Loader\ConsulLoader();
$config = new BeatLabs\Load\Config([$loader]);
$config->load();
// Get configuration values
$val = $config->get('var');
// You can get all available options here: https://docs.guzzlephp.org/en/6.5/quickstart.html#creating-a-client
$options = [
"base_uri" => "myhost:8000"
];
$loader = new BeatLabs\Load\Loader\ConsulLoader('services/my-service', $options);
$config = new BeatLabs\Load\Config([$loader]);
$config->load();
// Get configuration values
$val = $config->get('var');
// Set variable
$loader = new BeatLabs\Load\Loader\EnvLoader('PREFIX_'); // Define environment variables prefix to be loaded
$config = new BeatLabs\Load\Config([$loader]);
$config->load();
// Get configuration values
$val = $config->get('var');
$consulLoader = new BeatLabs\Load\Loader\ConsulLoader();
$fileLoader = new BeatLabs\Load\Loader\PHPLoader('config.php');
$envLoader = new BeatLabs\Load\Loader\EnvLoader('PREFIX_');
$config = new BeatLabs\Load\Config([$consulLoader, $fileLoader, $envLoader]);
$config->load();
// Get configuration values
$val = $config->get('var');
$cache = new CustomCache();
$loader = new BeatLabs\Load\Loader\PHPLoader('config.php'); // Config file
$config = new BeatLabs\Load\Config([$loader], $cache);
$config->load();