PHP code example of datahihi1 / tiny-env

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

    

datahihi1 / tiny-env example snippets




use Datahihi1\TinyEnv\TinyEnv;

$env = new TinyEnv(__DIR__);
$env->load();

echo env('DB_HOST', 'localhost');

$env->load();              // Load all
$env->load(['DB_HOST']);   // Load specific keys

$env = new TinyEnv(__DIR__, true); // Load immediately

$env->lazy(['DB']); // Load only DB_* variables

$env->safeLoad(); // Ignore missing/unreadable .env files

$env->envfiles(['.env', '.env.local', '.env.production']);

echo env('NAME');                // Get value
echo env('NOT_FOUND', 'backup'); // With default
print_r(env());                  // Get all (in .env file)
print_r(sysenv());               // Get all system variables

validate_env([
  'VERSION' => 'EBUG' => 'bool'
]);