PHP code example of sergeyakovlev / env
1. Go to this page and download the library: Download sergeyakovlev/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/ */
sergeyakovlev / env example snippets
use SergeYakovlev\Env\Env;
// If necessary non-default initialization
Env::init('/path/to/project', ['.env.dist', '.env']); // This is the default behavior
// The first use case
$dbHostname = Env::var('DB_HOSTNAME');
// The second use case is with the default value
$dbHostname = Env::var('DB_HOSTNAME', 'localhost');
// Check if an environment variable is existed
$dbHostnameIsExists = Env::exists('DB_HOSTNAME');