Fix database schema drop order, enhance migrate.php, and support server env paths
This commit is contained in:
@@ -30,15 +30,26 @@ spl_autoload_register(function ($class) {
|
||||
// 2. Load Environment Variables
|
||||
try {
|
||||
// Find the closest .env file path (supporting local development and CloudPanel server directories)
|
||||
$env_file = APP_ROOT . '/.env';
|
||||
if (!file_exists($env_file)) {
|
||||
if (file_exists(APP_ROOT . '/../../../.env')) {
|
||||
$env_file = APP_ROOT . '/../../../.env';
|
||||
} elseif (file_exists(APP_ROOT . '/../.env')) {
|
||||
$env_file = APP_ROOT . '/../.env';
|
||||
$candidatePaths = [
|
||||
APP_ROOT . '/.env',
|
||||
APP_ROOT . '/../.env',
|
||||
APP_ROOT . '/../../.env',
|
||||
APP_ROOT . '/../../../.env',
|
||||
APP_ROOT . '/../../../../.env',
|
||||
'/home/intaleqapp-saqel/.env'
|
||||
];
|
||||
$env_file = null;
|
||||
foreach ($candidatePaths as $path) {
|
||||
if (file_exists($path)) {
|
||||
$env_file = $path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
\App\Core\Env::load($env_file);
|
||||
if ($env_file) {
|
||||
\App\Core\Env::load($env_file);
|
||||
} else {
|
||||
throw new \RuntimeException("No .env file found in candidate paths");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// In production, log error; in development, print it
|
||||
error_log('Env Load Error: ' . $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user