1. Go to this page and download the library: Download phossa/phossa-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/ */
phossa / phossa-config example snippets
// returns an array
$db_config = $config->get('db');
// returns a string
$db_host = $config->get('db.auth.host');
# debugging true|false, change to 'false' ON production server
APP_DEBUG=true
# App environment, change to 'prod' ON production server
APP_ENV=dev
# app root directory, default to current dir
APP_ROOT=${__DIR__}
# central configuration directory
CONFIG_DIR=${APP_ROOT}/config
// load environment
(new Phossa\Config\Env\Environment())->load(__DIR__.'/.env');
// create config object
$config = new Phossa\Config\Config(
getenv('CONFIG_DIR'), // loaded from .env file
getenv('APP_ENV') // loaded from .env file
);
// load all configs in one shot
$conf_data = $config->get(null);
// create config object
$config = new Phossa\Config\Config(
dirname(__DIR__) . '/config', // the config dir
'staging/server2', // config env
'php', // file type
new Phossa\Config\Cache\Cache(__DIR__ . '/cache') // cache location
);
// if cache exists, this will read all configs from the cache
$conf_data = $config->get(null);
// ...
// write to cache
$config->save();
// group: system
return [
'tmpdir' => '/var/local/tmp',
...
];