1
+ <?php
2
+ /**
3
+ * @author Raiza Rhamdan (Leonardo DaVchezt) <[email protected] >
4
+ * @copyright Copyright (c), 2021 Raiza Rhamdan
5
+ * @license MIT public license
6
+ */
7
+
8
+ namespace app ;
9
+
10
+ defined ("__DAVCHEZT " ) or die ("{ \"response \" : \"error 403 \"} " );
11
+
12
+ use flight \Engine ;
13
+
14
+ /**
15
+ * The Engine class contains the core functionality of the framework.
16
+ * It is responsible for loading an HTTP request, running the assigned services,
17
+ * and generating an HTTP response.
18
+ *
19
+ * Core methods
20
+ * @method void start() Starts engine
21
+ * @method void stop() Stops framework and outputs current response
22
+ * @method void halt(int $code = 200, string $message = '') Stops processing and returns a given response.
23
+ *
24
+ *
25
+ * Routing
26
+ * @method void route(string $pattern, callable $callback, bool $pass_route = false) Routes a URL to a callback function.
27
+ * @method \flight\net\Router router() Gets router
28
+ *
29
+ * Views
30
+ * @method void render(string $file, array $data = null, string $key = null) Renders template
31
+ * @method \flight\template\View view() Gets current view
32
+ *
33
+ * Request-response
34
+ * @method \app\Net\AppRequest request() Gets current request
35
+ * @method \app\Net\AppResponse response() Gets current response
36
+ * @method void error(\Exception $e) Sends an HTTP 500 response for any errors.
37
+ * @method void notFound() Sends an HTTP 404 response when a URL is not found.
38
+ * @method void redirect(string $url, int $code = 303) Redirects the current request to another URL.
39
+ * @method void json(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSON response.
40
+ * @method void jsonp(mixed $data, string $param = 'jsonp', int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSONP response.
41
+ *
42
+ * HTTP caching
43
+ * @method void etag($id, string $type = 'strong') Handles ETag HTTP caching.
44
+ * @method void lastModified(int $time) Handles last modified HTTP caching.
45
+ */
46
+
47
+ class AppEngine extends Engine
48
+ {
49
+ protected $ appPath ;
50
+
51
+ public function __construct ($ path ) {
52
+ $ this ->appPath = $ path ;
53
+
54
+ parent ::__construct ();
55
+ }
56
+
57
+ public function init () {
58
+ parent ::init ();
59
+
60
+ $ this ->loader ->register ('request ' , 'app\Net\AppRequest ' , [$ this ->appPath ]);
61
+ $ this ->loader ->register ('response ' , 'app\Net\AppResponse ' );
62
+ $ this ->loader ->register ('helper ' , 'app\Helper ' );
63
+ $ this ->loader ->register ('plugin ' , 'app\Plugin ' );
64
+ $ this ->loader ->register ('logger ' , 'app\Logger ' );
65
+ $ this ->loader ->register ('mailer ' , 'app\Lib\Mailer ' );
66
+ $ this ->loader ->register ('jwt ' , 'app\Lib\JWTAuth ' );
67
+ $ this ->loader ->register ('db ' , 'app\Lib\Db ' );
68
+ }
69
+ }
0 commit comments