1. Go to this page and download the library: Download phpsoftbox/env 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/ */
phpsoftbox / env example snippets
declare(strict_types=1);
use PhpSoftBox\Env\Environment;
use PhpSoftBox\Env\EnvStorage;
$env = Environment::create(__DIR__ . '/config/env')
->setEnvironment(null) // null => APP_ENV процесса, затем из .env, иначе dev
->setPrefix('APP_');
$variables = $env->load();
$dbHost = $variables->get('DB_HOST');
$dbPort = $variables->toInt('DB_PORT', 3306);
$debug = $variables->toBool('APP_DEBUG', false);
// Типизированный доступ к текущему EnvStorage.
$debug = EnvStorage::value('APP_DEBUG')->bool(default: false);
$port = EnvStorage::value('DB_PORT')->int(default: 3306);