'config_missing', 'message' => '未找到 backend-web/config/local.php,请先写入生产配置。', ], JSON_UNESCAPED_UNICODE); exit; } } if (!is_array($config)) { http_response_code(500); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['error' => 'config_invalid'], JSON_UNESCAPED_UNICODE); exit; } if (!isset($config['app']) || !is_array($config['app'])) { $config['app'] = []; } if (!isset($config['app']['env'])) { $config['app']['env'] = 'production'; } if (!isset($config['app']['debug'])) { $config['app']['debug'] = false; } if ($config['app']['debug']) { ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); } else { ini_set('display_errors', '0'); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); } date_default_timezone_set($config['app']['timezone'] ?? 'Asia/Shanghai'); spl_autoload_register(static function (string $class): void { $prefixes = [ 'Soon\\Api\\' => SOON_API_ROOT . '/', 'Soon\\Admin\\' => SOON_API_ROOT . '/', ]; foreach ($prefixes as $prefix => $baseDir) { if (strpos($class, $prefix) !== 0) { continue; } $relative = substr($class, strlen($prefix)); $path = $baseDir . str_replace('\\', '/', $relative) . '.php'; if (is_file($path)) { require $path; return; } } }); require SOON_API_ROOT . '/Core/Config.php'; \Soon\Api\Core\Config::init($config); require SOON_API_ROOT . '/Services/PaymentConfigLoader.php'; require SOON_API_ROOT . '/Services/SettingsConfigLoader.php'; \Soon\Api\Services\PaymentConfigLoader::reload($config); \Soon\Api\Core\Config::init($config); require SOON_API_ROOT . '/Core/ErrorHandler.php'; \Soon\Api\Core\ErrorHandler::register();