1. Go to this page and download the library: Download sodaho/env-loader 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/ */
sodaho / env-loader example snippets
use Sodaho\EnvLoader\EnvLoader;
// Loads .env into $_ENV (does not overwrite existing, no
// Overwrite existing $_ENV variables
EnvLoader::load('.env', overwrite: true);
// Require specific keys (throws exception if missing)
EnvLoader::load('.env',
use Sodaho\EnvLoader\EnvLoader;
use Sodaho\EnvLoader\Exception\EnvLoaderException;
use Sodaho\EnvLoader\Exception\FileNotFoundException;
use Sodaho\EnvLoader\Exception\MissingRequiredKeyException;
try {
EnvLoader::load('.env',
// Safe
$host = $_ENV['DB_HOST'];
// Not recommended (not set by this loader)
$host = getenv('DB_HOST');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.