-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
63 lines (43 loc) · 1.53 KB
/
index.php
File metadata and controls
63 lines (43 loc) · 1.53 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once 'vendor/autoload.php';
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Slim\Slim;
date_default_timezone_set("America/New_York");
require 'config/config.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
$c = new \Slim\Container();
$c['errorHandler'] = function ($c) {
return function ($request, $response, $exception) use ($c) {
global $app;
$data = [
'status' => $exception->getCode(),
'error' => true,
'msg' => $exception->getMessage()
];
return $c['response']->withStatus($exception->getCode() != 0 ? $exception->getCode(): 500)
->withHeader('Content-Type', 'application/json')
->write(json_encode($data));
};
};
$c['mode'] = 'development';
$app = new \Slim\App($c);
$container = $app->getContainer();
require 'config/db.php';
r
$app->add(function (ServerRequestInterface $request, ResponseInterface $response, callable $next) {
// Use the PSR 7 $request object
return $next($request, $response);
});
$app->add(function($request, $response, $next) {
$response = $response->withHeader('Content-Type', 'application/json');
return $next($request, $response);
});
$app->group('', function() use ($app){
});
$app->run();