<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

header('Content-Type: text/plain');

echo "Current Dir: " . __DIR__ . "\n";
echo "DotEnv Path: " . __DIR__ . '/../../lib/DotEnv.php' . "\n";
echo "Env File Path: " . __DIR__ . '/../../.env' . "\n";

if (file_exists(__DIR__ . '/../../lib/DotEnv.php')) {
    echo "DotEnv file exists.\n";
    require_once __DIR__ . '/../../lib/DotEnv.php';
    echo "DotEnv loaded.\n";
} else {
    echo "DotEnv file NOT found.\n";
}

if (file_exists(__DIR__ . '/../../.env')) {
    echo ".env file exists.\n";
    try {
        (new DotEnv(__DIR__ . '/../../.env'))->load();
        echo ".env loaded.\n";
    } catch (Exception $e) {
        echo "Error loading .env: " . $e->getMessage() . "\n";
    }
} else {
    echo ".env file NOT found.\n";
}

$root = getenv('DOCUMENT_ROOT');
echo "DOCUMENT_ROOT from getenv: " . var_export($root, true) . "\n";
echo "DOCUMENT_ROOT from \$_ENV: " . var_export($_ENV['DOCUMENT_ROOT'] ?? 'unset', true) . "\n";
echo "DOCUMENT_ROOT from \$_SERVER: " . var_export($_SERVER['DOCUMENT_ROOT'] ?? 'unset', true) . "\n";
