1. Go to this page and download the library: Download waffle-commons/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/ */
waffle-commons / config example snippets
use Waffle\Commons\Config\Config;
use Waffle\Commons\Config\DotEnv;
use Waffle\Commons\Contracts\Enum\Failsafe;
// Build the env registry from .env + process env (rightmost wins → OS beats .env).
$envRegistry = array_merge(
(new DotEnv(__DIR__))->load(),
getenv() ?: [],
);
$config = new Config(
configDir: __DIR__ . '/config',
environment: 'prod',
failsafe: Failsafe::DISABLED,
env: $envRegistry,
);
$port = $config->getInt('http.port', default: 8080);
$debug = $config->getBool('app.debug', default: false);
$logs = $config->getArray('logging.channels', default: []);
$appName = $config->getString('app.name');
/**
* @param array<string, string> $env Read-only env registry consulted when
* resolving `%env(VAR)%` placeholders. Defaults to an empty map.
*/
public function __construct(
string $configDir,
string $environment,
Failsafe $failsafe = Failsafe::DISABLED,
array $env = [],
)