Initial habit tracker project

This commit is contained in:
2026-07-10 16:18:31 +02:00
commit 23416ee382
20 changed files with 1157 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
session_set_cookie_params([
'httponly' => true,
'samesite' => 'Lax',
'secure' => !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off',
]);
session_start();
require __DIR__ . '/../app/helpers.php';
require __DIR__ . '/../app/Core/Database.php';
require __DIR__ . '/../app/Core/View.php';
require __DIR__ . '/../app/Models/User.php';
require __DIR__ . '/../app/Models/Category.php';
require __DIR__ . '/../app/Models/Habit.php';
require __DIR__ . '/../app/Controllers/AuthController.php';
require __DIR__ . '/../app/Controllers/HabitController.php';
$route = $_GET['route'] ?? 'dashboard';
$method = $_SERVER['REQUEST_METHOD'];
$routes = [
'GET' => [
'login' => [AuthController::class, 'showLogin'],
'register' => [AuthController::class, 'showRegister'],
'dashboard' => [HabitController::class, 'dashboard'],
'habits/create' => [HabitController::class, 'create'],
'habits/edit' => [HabitController::class, 'edit'],
],
'POST' => [
'login' => [AuthController::class, 'login'],
'register' => [AuthController::class, 'register'],
'logout' => [AuthController::class, 'logout'],
'habits/store' => [HabitController::class, 'store'],
'habits/update' => [HabitController::class, 'update'],
'habits/delete' => [HabitController::class, 'delete'],
'habits/toggle' => [HabitController::class, 'toggle'],
],
];
if (!isset($routes[$method][$route])) {
http_response_code(404);
echo 'Seite nicht gefunden.';
exit;
}
[$controllerClass, $action] = $routes[$method][$route];
(new $controllerClass())->$action();