Load a .env file with PHP
PHP Snippet 1:
USER_NAME='jfBiswajit'
PHP Snippet 2:
<?php
require_once realpath(__DIR__ . '/vendor/autoload.php');
// Looing for .env at the root directory
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Retrive env variable
$userName = $_ENV['USER_NAME'];
echo $userName; //jfBiswajit