/** * Sets the correct route corresponding to request URI */ public function proceed() { $this->route = Router::getInstance()->search($this->uri); if (!$this->route) { throw new \Exception("Impossible to create the Route object for route {$this->route}"); } }
/** * @param $route_name * @param $params * @return mixed|string */ public static function url($route_name, $params = null) { return Router::getInstance()->generateRoute($route_name, $params); }
* Time: 11:04 */ define("ROOT", __DIR__ . '/..'); require_once ROOT . '/vendor/autoload.php'; use Got\Core\Config; use Got\Core\Debug; use Got\Core\Router; use Got\Core\Response; use Got\Core\Request; $conf = new Config(ROOT . "/config/config.json"); if (Config::get('debug')) { $debug = Debug::getInstance(); $sql = \Got\Core\Db::getInstance(); $debug->setupPdoCollector($sql->getConnection()); } $router = Router::getInstance(ROOT . Config::get('path')->routes_file); $request = new Request($_SERVER['REQUEST_URI']); $response = new Response(); try { $request->proceed(); $controller_name = ucfirst($request->getController()); $action_name = $request->getAction() . 'Action'; $class = '\\Got\\Action\\' . $controller_name; $controller = new $class($request, $response); if (!method_exists($controller, $action_name) || !$controller->{$action_name}()) { header('HTTP/1.1 404 Not Found'); echo "BOUH"; die; } $response->setTemplate($controller->getTemplate($action_name)); $response->render();