<?php $baseURI = $Config->get("application.baseURI"); $Router = new Aurora\Router($baseURI); $Router->any('/?{user}', ["App\\Controller\\Welcome", "sayHello"]); try { $found = $Router->findRoute($Router->findRequestMethod(), $Router->findUri()); } catch (RouteNotFoundException $Exception) { } catch (MethodNotAllowedException $Exception) { } return $found;
<?php include "../vendor/autoload.php"; use Aurora\MVC\Controller; class Home extends Controller { public function view($id) { } } $Injector = new Aurora\Injector(); $Injector->define("Aurora\\Http\\Request", [":GET" => $_GET, ":POST" => $_POST, ":COOKIE" => $_COOKIE, ":FILES" => $_FILES, ":SERVER" => $_SERVER]); $Config = new Aurora\Config(); $Application = new Aurora\Application($Config, $Injector); $Router = new Aurora\Router(); $Router->addRoute('GET', '/message/send/{id}', ["Home", "view"]); $found = $Router->findRoute('GET', '/message/send/John'); $Application->run($found["action"], $found["params"]);
<?php include __DIR__ . "./../../Router/src/Router.php"; // Autoload files using Composer require __DIR__ . "./../vendor/autoload.php"; // Autoload files using Composer $Router = new Aurora\Router("/home"); $Router->post('/', 'HomeController@index'); $Router->addRoute("GET", '/user/{id}/?{name}', 'UserController@show', "getUser", ["id" => "num"]); $Router->addRoute("GET", '/user/messages/{id}/?{toId}', 'UserController@show', "getMessage"); $Router->findRoute('GET', '/home/user/1'); $raw = $Router->getRawRoutes(); $url = new Aurora\Helper\Url($raw); # Usage // var_dump($url->withRoute("/user/{id}/?{name}", [ // "id" => 3, // "name" => "Samuell" // ]));