Initial Commit
This commit is contained in:
42
public/index.php
Normal file
42
public/index.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
use Latte\Engine;
|
||||
require "../vendor/autoload.php";
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/../");
|
||||
|
||||
try {
|
||||
$dotenv->load();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
// Set paths for controllers
|
||||
Flight::path("../app/controllers");
|
||||
Flight::path("../app/middlewares");
|
||||
|
||||
// Register latte view engine
|
||||
Flight::register("view", Engine::class, [], function ($latte) {
|
||||
$latte->setTempDirectory(__DIR__ . "/../cache/");
|
||||
$latte->setLoader(
|
||||
new \Latte\Loaders\FileLoader(__DIR__ . "/../app/views/"),
|
||||
);
|
||||
});
|
||||
|
||||
require "../app/routes.php";
|
||||
|
||||
// Login route
|
||||
Flight::route("GET /auth/login", function () {
|
||||
Auth::login("/admin");
|
||||
});
|
||||
|
||||
// Logout route
|
||||
Flight::route("GET /auth/logout", function () {
|
||||
Auth::logout();
|
||||
});
|
||||
|
||||
// API route to get current user data
|
||||
Flight::route("GET /debug/user", function () {
|
||||
$user = Auth::user();
|
||||
Flight::json($user);
|
||||
});
|
||||
|
||||
Flight::start();
|
||||
Reference in New Issue
Block a user