add bramus router inside the framework to add DI in future

This commit is contained in:
Gregory Letellier
2023-11-20 14:22:55 +01:00
parent de03a1f215
commit 07de5df32f
4 changed files with 555 additions and 28 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace Kletellier\Framework\Core\Routing;
use Kletellier\Framework\Core\Routing\Router;
use Kletellier\Framework\Core\Kernel\Container;
class Routing
{
private $_router;
private $_root;
public function __construct()
{
$this->_root = Container::get("ROOT");
$this->init();
}
public function run()
{
$this->_router->run();
}
private function init()
{
$this->_router = new Router();
$this->loadFromFile($this->_root . DIRECTORY_SEPARATOR . "routes");
$this->_router->set404("404 - Not found");
}
private function loadFromFile($path)
{
if (is_dir($path)) {
$router = $this->_router;
require $path . DIRECTORY_SEPARATOR . "routes.php";
}
}
}