forked from BobCoderS9/SSPanel-Metron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.php
42 lines (34 loc) · 984 Bytes
/
container.php
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
<?php
declare(strict_types=1);
use Slim\Container;
/**
* Container Builder
*
* @return Container
*/
$configuration = [
'settings' => [
'debug' => $_ENV['debug'],
'whoops.editor' => 'sublime',
'displayErrorDetails' => $_ENV['debug'],
]
];
$container = new Container($configuration);
$container['notFoundHandler'] = static function ($c) {
return static function ($request, $response) use ($c) {
return $response->withAddedHeader('Location', '/404');
};
};
$container['notAllowedHandler'] = static function ($c) {
return static function ($request, $response, $methods) use ($c) {
return $response->withAddedHeader('Location', '/405');
};
};
if ($_ENV['debug'] === false) {
$container['errorHandler'] = static function ($c) {
return static function ($request, $response, $exception) use ($c) {
return $response->withAddedHeader('Location', '/500');
};
};
}
return $container;