-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
34 lines (26 loc) · 897 Bytes
/
index.php
File metadata and controls
34 lines (26 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/bootstrap.php';
$routes = array_merge(
include(__DIR__ . '/routes/api.php'),
include(__DIR__ . '/routes/web.php'),
);
$uri = $_SERVER['PATH_INFO'] ?? '/';
$method = mb_strtolower($_SERVER['REQUEST_METHOD']);
$response = null;
foreach ($routes as $routeUri => $route) {
$routeUri = addcslashes($routeUri, '/');
preg_match("/^$routeUri$/", $uri, $params);
if (count($params) > 0) {
$controller = new $route[$method]['controller'];
$controllerMethod = $route[$method]['method'];
$response = $controller->$controllerMethod($params);
// $response = $controller->$controllerMethod(
// ...array_filter($params, fn($key) => !is_int($key), ARRAY_FILTER_USE_KEY)
// );
break;
}
}
echo $response;