-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.php
More file actions
38 lines (24 loc) · 947 Bytes
/
Index.php
File metadata and controls
38 lines (24 loc) · 947 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
35
36
37
38
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
http_response_code(200);
exit;
}
use App\Service\WorkWithJson\Request;
use App\Container\Container;
use App\Routes\Routes;
use App\Model\DatabaseConfig\DatabaseConnect;
require 'vendor/autoload.php';
$db = new DatabaseConnect();
$pdo = $db->getConnection();
$container = new Container();
$container->registerClassesInDirectory(__DIR__ . '/src');
$container->registerInstance(\PDO::class, $pdo);
$request = $container->get(Request::class)->getRequest();
$url = $request['url'];
$method = $request['method'];
$routes = new Routes();
$routes->routes($container, $url, $method);