This commit is contained in:
2024-07-29 15:57:20 +03:00
parent 95f56a04d3
commit 200763725e
34 changed files with 936 additions and 72 deletions

48
kernel/App.php Normal file
View File

@ -0,0 +1,48 @@
<?php
namespace kernel;
use app\helpers\Debug;
use Phroute\Phroute\Dispatcher;
class App
{
static string $responseType = ResponseType::TEXT_HTML;
static CgRouteCollector $collector;
static Header $header;
public static Database $db;
public function run(): void
{
$dispatcher = new Dispatcher(App::$collector->getData());
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
header('Content-Type: ' . App::$responseType);
App::$header->set();
echo $response;
}
public function load(): static
{
App::$collector = new CgRouteCollector();
$this->setRouting();
return $this;
}
public function setRouting(): void
{
include ROOT_DIR . "/rout.php";
}
public static function create(): App
{
return new self();
}
}