Add error handling for missing vendor to prevent 500 Empty Body errors

This commit is contained in:
Hamza-Ayed
2026-08-01 05:44:25 +03:00
parent 84c725040f
commit d0ab3653dd
2 changed files with 12 additions and 1 deletions
+8 -1
View File
@@ -1,6 +1,13 @@
<?php
// Load environment variables from .env file
require_once realpath(__DIR__ . '/../vendor/autoload.php');
$autoloadPath = realpath(__DIR__ . '/../vendor/autoload.php');
if ($autoloadPath) {
require_once $autoloadPath;
} else {
http_response_code(500);
echo json_encode(['status' => 'failure', 'message' => 'Vendor autoload missing in location server. Please run composer install.']);
exit;
}
require_once __DIR__ . '/load_env.php';
$env_file = file_exists(__DIR__ . '/../loction-keys/.env')
+4
View File
@@ -9,6 +9,10 @@
$autoload = __DIR__ . '/../vendor/autoload.php';
if (file_exists($autoload)) {
require_once $autoload;
} else {
http_response_code(500);
echo json_encode(['status' => 'failure', 'message' => 'Vendor autoload missing. Please run composer install.']);
exit;
}
// 2. لا حاجة لتحميل .env يدوياً: Docker يحقن المتغيّرات عبر env_file