fix: Enable dynamic student/teacher contact discovery, dual REST/WebSocket persistence, and multi-path .env detection

This commit is contained in:
Hamza-Ayed
2026-08-27 03:47:45 +03:00
parent b11a4bd8c1
commit 7fd67756b4
4 changed files with 198 additions and 140 deletions
+22 -11
View File
@@ -25,19 +25,30 @@ spl_autoload_register(function ($class) {
}
});
// 2. Load Environment Variables (Fixed Dedicated CloudPanel Path: /home/intaleqapp-saqel/.env)
// 2. Load Environment Variables with Multi-Path Fallback
try {
// Fixed CloudPanel root path on server, with local fallback for local development
$env_file = file_exists('/home/intaleqapp-saqel/.env')
? '/home/intaleqapp-saqel/.env'
: APP_ROOT . '/.env';
$candidatePaths = [
'/home/intaleqapp-saqel/.env',
'/home/intaleqapp-saqel/htdocs/saqel.intaleqapp.com/.env',
'/home/intaleqapp-saqel/htdocs/saqel.intaleqapp.com/saqel/.env',
'/home/intaleqapp-saqel/htdocs/saqel.intaleqapp.com/saqel/backend/.env',
APP_ROOT . '/.env',
APP_ROOT . '/../.env'
];
if (file_exists($env_file)) {
define('LOADED_ENV_PATH', $env_file);
\App\Core\Env::load($env_file);
} else {
define('LOADED_ENV_PATH', 'NOT_FOUND: ' . $env_file);
error_log("⚠️ [Env Warning] .env file not found at: {$env_file}");
$loaded = false;
foreach ($candidatePaths as $path) {
if (file_exists($path)) {
define('LOADED_ENV_PATH', $path);
\App\Core\Env::load($path);
$loaded = true;
break;
}
}
if (!$loaded) {
define('LOADED_ENV_PATH', 'NOT_FOUND');
error_log("⚠️ [Env Warning] .env file not found in any candidate path");
}
} catch (\Exception $e) {
error_log('Env Load Error: ' . $e->getMessage());