Files
FACULTATE-KNOW_YOUR_FOOD/knowyourfood/core/Application.php
T

42 lines
1014 B
PHP
Executable File

<?php
namespace app\core;
use AllowDynamicProperties;
use app\exceptions\ForbiddenAccessException;
use app\exceptions\PageNotFoundException;
#[AllowDynamicProperties] class Application
{
public static string $ROOT_DIR;
public static Application $app;
public Router $router;
public Request $request;
public Response $response;
public ?Controller $controller = null;
public Session $session;
public View $view;
public function __construct()
{
self::$ROOT_DIR = dirname(__DIR__);
self::$app = $this;
$this->request = new Request();
$this->response = new Response();
$this->router = new Router($this->request);
$this->view = new View();
$this->session = new Session();
}
public function run(): void
{
try{
echo $this->router->resolve();
}catch(ForbiddenAccessException $e){
}catch(PageNotFoundException $e){
}
}
}