query('SELECT 1 AS healthy'); $healthy = (int) ($statement ? $statement->fetchColumn() : 0) === 1; http_response_code($healthy ? 200 : 500); echo json_encode([ 'status' => $healthy ? 'ok' : 'error', 'database' => $healthy ? 'ok' : 'error', 'checked_at' => gmdate('c'), ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); } catch (Throwable $exception) { http_response_code(500); echo json_encode([ 'status' => 'error', 'database' => 'error', 'checked_at' => gmdate('c'), ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); }