PHP code example of gullevek / dotenv

1. Go to this page and download the library: Download gullevek/dotenv 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/ */

    

gullevek / dotenv example snippets



$status = \gullevek\dotEnv\DotEnv::readEnvFile(__DIR__);

public static function readEnvFile(
    string $path = __DIR__,
    string $env_file = '.env',
    bool $load_outside_env = false,
    bool $throw_exception = false,
): DotEnvLevel

public static function loadOutsideGetEnv(
    array $env_list = [],
    int $merge_flag = self::OVERWRITE
): void



use gullevek\dotEnv\Exceptions;

try {
    $status = gullevek\dotEnv\DotEnv::readEnvFile(throw_exceptions: true);
} catch (Exception\DotEnvFileOpenFailedException $e) {
    // file not found/not readable/open failed
}

$_ENV["FOO"];
$_ENV["FOOBAR"];
$_ENV["SecitonA.FOO"];
$_ENV["SecitonA.FOOBAR"];