PHP .env package fails on Glitch

Hello, I’ve been working on getting a login system up and running for one of my apps. To hide tokens, I’m using a the vlucas/phpdotenv package, which I’ved used in the past with no issues.

Unfortunately, the program refuses to show anything in the .env files. After running print_r($_ENV) to debug, it was an empty array:


require __DIR__ . "/vendor/autoload.php";

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);


// output is Array ( ) 1

I’ve tried messing around with the createImmutable() function and giving it the “app” directory but nothing seems to be working. The only errors in the error log is that the index “client” and “secret” cannot be found because $_ENV is a blank array, which it should not be. I’ve used this package on my own server and it works just fine. What is going wrong here?

Sometimes PHP apps work weirdly, so I use this:

function readEnv($var) {
    return exec("echo $var");
function addEnv($var,$val) {
    $f = '/app/.env';
    $c = file_get_contents($file);
    $c .= "$var=$val\n";
    file_put_contents($f, $c);
function removeEnv($var2,$val2) {
    $cont = file_get_contents($dir);
    $cont = str_replace($rem, '', $cont);
    file_put_contents($dir, $cont);