-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathbootstrap.php
39 lines (33 loc) · 1017 Bytes
/
bootstrap.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
<?php
/**
* @global string $context
*/
namespace My\Hello;
use BEAR\Package\Bootstrap;
use Doctrine\Common\Annotations\AnnotationRegistry;
load: {
/* @var $loader \Composer\Autoload\ClassLoader */
$loader = require dirname(__DIR__) . '/vendor/autoload.php';
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
}
route: {
$app = (new Bootstrap)->getApp(__NAMESPACE__, $context);
/* @var $app AbstractApp \BEAR\Sunday\Extension\Application\AbstractApp */
$request = $app->router->match($GLOBALS, $_SERVER);
}
try {
// resource request
$page = $app->resource
->{$request->method}
->uri($request->path)
->withQuery($request->query)
->request();
/* @var $page \BEAR\Resource\Request */
// representation transfer
$page()->transfer($app->responder, $_SERVER);
echo require dirname(__FILE__).'/../../libs/output_data.php';
exit(0);
} catch (\Exception $e) {
$app->error->handle($e, $request)->transfer();
exit(1);
}