first commit
This commit is contained in:
34
public/index.php
Normal file
34
public/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set("display_errors", 1);
|
||||
|
||||
session_start([
|
||||
'cookie_lifetime' => 86400,
|
||||
'cookie_secure' => true,
|
||||
'cookie_httponly' => true,
|
||||
'cookie_samesite' => 'Strict'
|
||||
]);
|
||||
|
||||
if(empty($_SESSION['token']))
|
||||
$_SESSION['token'] = bin2hex(random_bytes(32));
|
||||
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
use Blog\Core\router;
|
||||
use Blog\Core\container;
|
||||
use Blog\Template\twig;
|
||||
use Blog\Utils\authHelper;
|
||||
|
||||
AuthHelper::initialize(new Blog\Model\userModel());
|
||||
$router = new Router();
|
||||
$container = new Container();
|
||||
|
||||
$container->set('twig', fn() => new Twig(__DIR__ . "/../views"));
|
||||
$container->set('postModel', fn() => new Blog\Model\postModel());
|
||||
|
||||
require_once __DIR__ . "/../routes/web.php";
|
||||
|
||||
$router->dispatch(
|
||||
new Blog\Http\request($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']),
|
||||
new Blog\Http\response
|
||||
);
|
Reference in New Issue
Block a user