Initial commit

This commit is contained in:
1xDed committed 2025-10-28 01:39:22 +03:00
commit 8d1473935a
23 files changed
+870

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* API v1 Entry Point
* Docker Container: php-fpm-v1
* Endpoint: /api/v1/
*/
header('Content-Type: application/json');
// Проверяем подключение к PostgreSQL
try {
$pdo = new PDO(
"pgsql:host=" . getenv('DB_HOST') . ";dbname=" . getenv('DB_NAME'),
getenv('DB_USER'),
getenv('DB_PASS')
);
$db_status = "connected";
} catch (PDOException $e) {
$db_status = "error: " . $e->getMessage();
}
// Проверяем подключение к Memcached
try {
$memcached = new Memcached();
$memcached->addServer(getenv('MEMCACHED_HOST'), 11211);
$memcached_status = $memcached->set('test_key', 'test_value', 10) ? "connected" : "error";
} catch (Exception $e) {
$memcached_status = "error: " . $e->getMessage();
}
// Формируем ответ
$response = [
'api_version' => 'v1',
'status' => 'success',
'timestamp' => time(),
'services' => [
'postgresql' => $db_status,
'memcached' => $memcached_status,
],
'container' => gethostname(),
'php_version' => PHP_VERSION,
];
echo json_encode($response, JSON_PRETTY_PRINT);