Compare commits
No commits in common. "d0760ed95cf8515a51248e6e936bb2b8d043652a" and "0111ef9525d19122656233806b30b2ba93bae4d2" have entirely different histories.
d0760ed95c
...
0111ef9525
14 changed files with 116 additions and 461 deletions
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers;
|
|
||||||
|
|
||||||
use Core\Controllers\Controller;
|
|
||||||
use Core\View\Render;
|
|
||||||
|
|
||||||
class TestController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Render index
|
|
||||||
*
|
|
||||||
* @return \Core\View\Render
|
|
||||||
*/
|
|
||||||
public function test(int $id): Render
|
|
||||||
{
|
|
||||||
|
|
||||||
dd($id);
|
|
||||||
|
|
||||||
return $this->response->view('subnet');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
use App\Controllers\Api\SubnetController;
|
use App\Controllers\Api\SubnetController;
|
||||||
use App\Controllers\HomeController;
|
use App\Controllers\HomeController;
|
||||||
use App\Controllers\TestController;
|
use Core\Router\Router;
|
||||||
use Core\Routing\Route;
|
|
||||||
|
|
||||||
Route::get('/', HomeController::class, 'index');
|
Router::get('/', HomeController::class, 'index');
|
||||||
Route::post('/api/subnet', SubnetController::class, 'data');
|
Router::post('/api/subnet', SubnetController::class, 'data');
|
||||||
Route::get('/test/{id}', TestController::class, 'test');
|
|
||||||
Route::get('/test/{id}/update', TestController::class, 'test');
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Core\Env\Env;
|
use Core\Env\Env;
|
||||||
use Core\Routing\Router;
|
use Core\Router\Router;
|
||||||
|
|
||||||
require '../vendor/autoload.php';
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,5 @@ class Exceptions
|
||||||
public static function catchOne(Throwable $exception): void
|
public static function catchOne(Throwable $exception): void
|
||||||
{
|
{
|
||||||
self::instance()->handleException($exception);
|
self::instance()->handleException($exception);
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Exceptions\Exceptions;
|
|
||||||
|
|
||||||
class HttpException extends \Exception {}
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Exceptions\Exceptions;
|
|
||||||
|
|
||||||
class InvalidArgumentException extends \InvalidArgumentException {}
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Exceptions\Exceptions;
|
|
||||||
|
|
||||||
class NotFoundHttpException extends HttpException {}
|
|
|
@ -2,25 +2,8 @@
|
||||||
|
|
||||||
namespace Core\Http;
|
namespace Core\Http;
|
||||||
|
|
||||||
use Core\Exceptions\Exceptions;
|
|
||||||
|
|
||||||
class Request
|
class Request
|
||||||
{
|
{
|
||||||
private array $data = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build request object
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function __construct(array $data)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
|
|
||||||
// Capture all exceptions
|
|
||||||
Exceptions::catch($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get request method
|
* Get request method
|
||||||
*
|
*
|
||||||
|
@ -60,7 +43,7 @@ class Request
|
||||||
*/
|
*/
|
||||||
public final function has(string $param): bool
|
public final function has(string $param): bool
|
||||||
{
|
{
|
||||||
return isset($this->data[$param]);
|
return isset($_POST[$param]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,11 +56,11 @@ class Request
|
||||||
public final function get(string|null $param = null, mixed $default = null): mixed
|
public final function get(string|null $param = null, mixed $default = null): mixed
|
||||||
{
|
{
|
||||||
if($param == null) {
|
if($param == null) {
|
||||||
return $this->data;
|
return $_POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->has($param)) {
|
if($this->has($param)) {
|
||||||
return $this->data[$param];
|
return $_POST[$param];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $default;
|
return $default;
|
||||||
|
|
109
src/Router/Router.php
Normal file
109
src/Router/Router.php
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Core\Router;
|
||||||
|
|
||||||
|
use Core\Exceptions\Exceptions;
|
||||||
|
use Core\Http\Request;
|
||||||
|
use Core\View\Render;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class Router
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of routes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static array $routes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add GET route
|
||||||
|
*
|
||||||
|
* @param string $route
|
||||||
|
* @param string $controller
|
||||||
|
* @param string $action
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function get(string $route, string $controller, string $action): void
|
||||||
|
{
|
||||||
|
self::register($route, $controller, $action, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add POST route
|
||||||
|
*
|
||||||
|
* @param string $route
|
||||||
|
* @param string $controller
|
||||||
|
* @param string $action
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function post(string $route, string $controller, string $action): void
|
||||||
|
{
|
||||||
|
self::register($route, $controller, $action, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register route
|
||||||
|
*
|
||||||
|
* @param string $route
|
||||||
|
* @param string $controller
|
||||||
|
* @param string $action
|
||||||
|
* @param string $method
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function register(string $route, string $controller, string $action, string $method): void
|
||||||
|
{
|
||||||
|
self::$routes[$method][$route] = [
|
||||||
|
'controller' => $controller,
|
||||||
|
'action' => $action,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch router and run application
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function dispatch(): void
|
||||||
|
{
|
||||||
|
// Init request
|
||||||
|
$request = new Request();
|
||||||
|
$url = $request->url();
|
||||||
|
$method = $request->method();
|
||||||
|
|
||||||
|
// Capture all exceptions
|
||||||
|
Exceptions::catch($request);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (array_key_exists($url, self::$routes[$method])) {
|
||||||
|
$controllerName = self::$routes[$method][$url]['controller'];
|
||||||
|
$actionName = self::$routes[$method][$url]['action'];
|
||||||
|
|
||||||
|
// Check for controller existence
|
||||||
|
if (!class_exists($controllerName)) {
|
||||||
|
throw new Exception(sprintf("Controller '%s' missing", $controllerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create controller object
|
||||||
|
$controller = new $controllerName($request);
|
||||||
|
|
||||||
|
// Check for method on controller
|
||||||
|
if (!method_exists($controller, $actionName)) {
|
||||||
|
throw new Exception(sprintf("Method '%s' not found on '%s'", $actionName, $controllerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build response object of action
|
||||||
|
$response = $controller->$actionName();
|
||||||
|
|
||||||
|
// Render action
|
||||||
|
if ($response instanceof Render) {
|
||||||
|
$response->render();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception(sprintf("No route found for: %s", $url));
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Exceptions::catchOne($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Routing;
|
|
||||||
|
|
||||||
class Route
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Add GET route
|
|
||||||
*
|
|
||||||
* @param string $route
|
|
||||||
* @param string $controller
|
|
||||||
* @param string $action
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function get(string $route, string $controller, string $action): void
|
|
||||||
{
|
|
||||||
RouteCollection::register($route, $controller, $action, 'GET');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add POST route
|
|
||||||
*
|
|
||||||
* @param string $route
|
|
||||||
* @param string $controller
|
|
||||||
* @param string $action
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function post(string $route, string $controller, string $action): void
|
|
||||||
{
|
|
||||||
RouteCollection::register($route, $controller, $action, 'POST');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Routing;
|
|
||||||
|
|
||||||
class RouteCollection
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A majestic vault of all defined routes.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected static array $routes = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a route to the sacred collection.
|
|
||||||
*
|
|
||||||
* @param string $route
|
|
||||||
* @param string $controller
|
|
||||||
* @param string $action
|
|
||||||
* @param string $method
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function register(string $route, string $controller, string $action, string $method): void
|
|
||||||
{
|
|
||||||
// Transform human-readable route syntax into regex.
|
|
||||||
$routeRegex = self::convertToRegex($route);
|
|
||||||
|
|
||||||
// Store the route in the sacred collection
|
|
||||||
self::$routes[$method][$routeRegex] = [
|
|
||||||
'controller' => $controller,
|
|
||||||
'action' => $action,
|
|
||||||
'original' => $route,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reveal the treasure trove of routes.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function retrieve(): array
|
|
||||||
{
|
|
||||||
return self::$routes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a route pattern into a regex for matching requests.
|
|
||||||
*
|
|
||||||
* @param string $route
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected static function convertToRegex(string $route): string
|
|
||||||
{
|
|
||||||
$regex = preg_replace('/\{([a-zA-Z0-9_]+)\}/', '(?P<\1>[a-zA-Z0-9_-]+)', $route);
|
|
||||||
return '#^' . $regex . '$#';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a specific route by method and URL.
|
|
||||||
*
|
|
||||||
* @param string $method
|
|
||||||
* @param string $url
|
|
||||||
* @return array|null
|
|
||||||
*/
|
|
||||||
public static function find(string $method, string $url): ?array
|
|
||||||
{
|
|
||||||
foreach (self::$routes[$method] ?? [] as $routeRegex => $route) {
|
|
||||||
if (preg_match($routeRegex, $url, $matches)) {
|
|
||||||
$route['params'] = array_filter(
|
|
||||||
$matches,
|
|
||||||
fn($key) => !is_numeric($key),
|
|
||||||
ARRAY_FILTER_USE_KEY
|
|
||||||
);
|
|
||||||
return $route;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purge all routes from the collection.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function clear(): void
|
|
||||||
{
|
|
||||||
self::$routes = [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Routing;
|
|
||||||
|
|
||||||
use Core\Env\Env;
|
|
||||||
use Core\Exceptions\Exceptions;
|
|
||||||
use Core\Exceptions\Exceptions\NotFoundHttpException;
|
|
||||||
use Core\Http\Request;
|
|
||||||
use Core\View\Render;
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class RouteDispatcher
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Current request instance
|
|
||||||
*
|
|
||||||
* @var \Core\Http\Request
|
|
||||||
*/
|
|
||||||
private Request $request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collection of all routes
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private array $routeCollection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Core\Http\Request $request
|
|
||||||
* @param array $routeCollection
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request, array $routeCollection)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
$this->routeCollection = $routeCollection;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$route = $this->findMatchingRoute();
|
|
||||||
$controller = $this->instantiateController($route['controller']);
|
|
||||||
$action = $this->validateActionExists($controller, $route['action']);
|
|
||||||
$params = $this->resolveParameters($controller, $action, $route['params'] ?? []);
|
|
||||||
|
|
||||||
$this->executeAction($controller, $action, $params);
|
|
||||||
} catch (NotFoundHttpException $e) {
|
|
||||||
$this->handleException($e, 404, 'page not found');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->handleException($e, 500, 'something went wrong');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function dispatch(Request $request, array $routeCollection): void
|
|
||||||
{
|
|
||||||
new self($request, $routeCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Locate a matching route for the incoming request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Core\Exceptions\Exceptions\NotFoundHttpException
|
|
||||||
*/
|
|
||||||
private function findMatchingRoute(): array
|
|
||||||
{
|
|
||||||
$url = $this->request->url();
|
|
||||||
$method = $this->request->method();
|
|
||||||
|
|
||||||
foreach ($this->routeCollection[$method] ?? [] as $routeRegex => $route) {
|
|
||||||
if (preg_match($routeRegex, $url, $matches)) {
|
|
||||||
$params = array_filter(
|
|
||||||
$matches,
|
|
||||||
fn($key) => !is_numeric($key),
|
|
||||||
ARRAY_FILTER_USE_KEY
|
|
||||||
);
|
|
||||||
return array_merge($route, ['params' => $params]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotFoundHttpException(sprintf("No route found for: %s", $url));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an instance of the requested controller.
|
|
||||||
*
|
|
||||||
* @param string $controllerName
|
|
||||||
* @return object
|
|
||||||
* @throws \Core\Exceptions\Exceptions\NotFoundHttpException
|
|
||||||
*/
|
|
||||||
private function instantiateController(string $controllerName): object
|
|
||||||
{
|
|
||||||
if (!class_exists($controllerName)) {
|
|
||||||
throw new NotFoundHttpException(sprintf("Controller '%s' missing", $controllerName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new $controllerName($this->request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that the action exists in the controller.
|
|
||||||
*
|
|
||||||
* @param object $controller
|
|
||||||
* @param string $actionName
|
|
||||||
* @return string
|
|
||||||
* @throws \Core\Exceptions\Exceptions\NotFoundHttpException
|
|
||||||
*/
|
|
||||||
private function validateActionExists(object $controller, string $actionName): string
|
|
||||||
{
|
|
||||||
if (!method_exists($controller, $actionName)) {
|
|
||||||
throw new NotFoundHttpException(sprintf("Method '%s' not found on '%s'", $actionName, get_class($controller)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $actionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate and resolve parameters for the controller action.
|
|
||||||
*
|
|
||||||
* @param object $controller
|
|
||||||
* @param string $action
|
|
||||||
* @param array $params
|
|
||||||
* @return array
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
private function resolveParameters(object $controller, string $action, array $params): array
|
|
||||||
{
|
|
||||||
return RouteValidator::resolve($controller, $action, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the resolved action on the controller with validated parameters.
|
|
||||||
*
|
|
||||||
* @param object $controller
|
|
||||||
* @param string $action
|
|
||||||
* @param array $params
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function executeAction(object $controller, string $action, array $params): void
|
|
||||||
{
|
|
||||||
$response = $controller->$action(...$params);
|
|
||||||
|
|
||||||
if ($response instanceof Render) {
|
|
||||||
$response->render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle exceptions gracefully.
|
|
||||||
*
|
|
||||||
* @param Exception $e
|
|
||||||
* @param int $statusCode
|
|
||||||
* @param string $message
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function handleException(Exception $e, int $statusCode, string $message): void
|
|
||||||
{
|
|
||||||
if (Env::get('debug')) {
|
|
||||||
Exceptions::catchOne($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
http_response_code($statusCode);
|
|
||||||
echo $message;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Routing;
|
|
||||||
|
|
||||||
use Core\Exceptions\Exceptions\NotFoundHttpException;
|
|
||||||
use ReflectionMethod;
|
|
||||||
use ReflectionNamedType;
|
|
||||||
|
|
||||||
class RouteValidator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Validate parameters against the method signature.
|
|
||||||
*
|
|
||||||
* @param object $controller
|
|
||||||
* @param string $action
|
|
||||||
* @param array $params
|
|
||||||
* @return array
|
|
||||||
* @throws \Core\Exceptions\Exceptions\NotFoundHttpException
|
|
||||||
* @throws \ReflectionException
|
|
||||||
*/
|
|
||||||
public static function resolve(object $controller, string $action, array $params): array
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionMethod($controller, $action);
|
|
||||||
$methodParameters = $reflection->getParameters();
|
|
||||||
$validatedParams = [];
|
|
||||||
|
|
||||||
foreach ($methodParameters as $methodParameter) {
|
|
||||||
$paramName = $methodParameter->getName();
|
|
||||||
$paramType = $methodParameter->getType();
|
|
||||||
$isOptional = $methodParameter->isOptional();
|
|
||||||
$defaultValue = $isOptional ? $methodParameter->getDefaultValue() : null;
|
|
||||||
|
|
||||||
if (!array_key_exists($paramName, $params)) {
|
|
||||||
if ($isOptional) {
|
|
||||||
$validatedParams[$paramName] = $defaultValue;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
throw new NotFoundHttpException(sprintf("Missing parameter '%s' for action '%s'", $paramName, $action));
|
|
||||||
}
|
|
||||||
|
|
||||||
$value = $params[$paramName];
|
|
||||||
$validatedParams[$paramName] = self::validateType($paramName, $value, $paramType, $action);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $validatedParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate and cast a parameter based on its type.
|
|
||||||
*
|
|
||||||
* @param string $paramName
|
|
||||||
* @param mixed $value
|
|
||||||
* @param ReflectionNamedType|null $paramType
|
|
||||||
* @param string $action
|
|
||||||
* @return mixed
|
|
||||||
* @throws \Core\Exceptions\Exceptions\NotFoundHttpException
|
|
||||||
*/
|
|
||||||
private static function validateType(string $paramName, mixed $value, ?ReflectionNamedType $paramType, string $action): mixed
|
|
||||||
{
|
|
||||||
if (!$paramType || $paramType->allowsNull() && $value === null) {
|
|
||||||
return $value; // No type or allows null, return as-is.
|
|
||||||
}
|
|
||||||
|
|
||||||
$typeName = $paramType->getName();
|
|
||||||
|
|
||||||
switch ($typeName) {
|
|
||||||
case 'int':
|
|
||||||
if (!ctype_digit((string)$value)) {
|
|
||||||
throw new NotFoundHttpException(sprintf("Invalid type for parameter '%s'. Expected integer, got '%s'", $paramName, gettype($value)));
|
|
||||||
}
|
|
||||||
return (int)$value;
|
|
||||||
|
|
||||||
case 'float':
|
|
||||||
if (!is_numeric($value)) {
|
|
||||||
throw new NotFoundHttpException(sprintf("Invalid type for parameter '%s'. Expected float, got '%s'", $paramName, gettype($value)));
|
|
||||||
}
|
|
||||||
return (float)$value;
|
|
||||||
|
|
||||||
case 'string':
|
|
||||||
if (!is_string($value)) {
|
|
||||||
throw new NotFoundHttpException(sprintf("Invalid type for parameter '%s'. Expected string, got '%s'", $paramName, gettype($value)));
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new NotFoundHttpException(sprintf("Unsupported type '%s' for parameter '%s'", $typeName, $paramName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Core\Routing;
|
|
||||||
|
|
||||||
use Core\Http\Request;
|
|
||||||
|
|
||||||
class Router
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Dispatch router and run application
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function dispatch(): void
|
|
||||||
{
|
|
||||||
// Create request
|
|
||||||
$request = new Request($_POST + $_FILES);
|
|
||||||
|
|
||||||
// Dispatch router
|
|
||||||
RouteDispatcher::dispatch($request, RouteCollection::retrieve());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue