1: <?php
2:
3: namespace PHPixie;
4:
5: /**
6: * PHPixie Framework Base.
7: *
8: * Extend it to build your own framework on top of PHPixie.
9: */
10: abstract class Framework
11: {
12: /**
13: * @var Framework\Builder
14: */
15: protected $builder;
16:
17: /**
18: * Constructor
19: */
20: public function __construct()
21: {
22: $this->builder = $this->buildBuilder();
23: }
24:
25: /**
26: * The main framework factory
27: * @return Framework\Builder
28: */
29: public function builder()
30: {
31: return $this->builder;
32: }
33:
34: /**
35: * Process HTTP request built from PHP globals
36: * and output the response
37: * @return void
38: */
39: public function processHttpSapiRequest()
40: {
41: $this->builder->http()->processSapiRequest();
42: }
43:
44: /**
45: * Process a PSR7 ServerRequest and get a PSR7 Response
46: * @param \Psr\Http\Message\ServerRequestInterface
47: * @return \Psr\Http\Message\ResponseInterface
48: */
49: public function processHttpServerRequest($serverRequest)
50: {
51: return $this->builder->http()->processServerRequest($serverRequest);
52: }
53:
54: /**
55: * Register error and exception handlers
56: * @param bool $shutdownLog Whether to output log contents at shutdown
57: * @param bool $exception Whether to catch and dump exceptions
58: * @param bool $error Whether to convert errors to exceptions
59: * @return void
60: */
61: public function registerDebugHandlers($shutdownLog = false, $exception = true, $error = true)
62: {
63: $debug = $this->builder->components()->debug();
64: $debug->registerHandlers($shutdownLog, $exception, $error);
65: }
66:
67: /**
68: * @return Framework\Builder
69: */
70: abstract protected function buildBuilder();
71: }