|
1 | 1 | <?php |
2 | | -/* |
3 | | -|-------------------------------------------------------------------------- |
4 | | -| Register The Auto Loader |
5 | | -|-------------------------------------------------------------------------- |
6 | | -| |
7 | | -| Composer provides a convenient, automatically generated class loader |
8 | | -| for our application. We just need to utilize it! We'll require it |
9 | | -| into the script here so that we do not have to worry about the |
10 | | -| loading of any our classes "manually". Feels great to relax. |
11 | | -| |
12 | | -*/ |
13 | | -require_once __DIR__ . '/vendor/autoload.php'; |
14 | 2 |
|
15 | | -/* |
16 | | -|-------------------------------------------------------------------------- |
17 | | -| Bring in (env) |
18 | | -|-------------------------------------------------------------------------- |
19 | | -| |
20 | | -| Quickly use our environment variables |
21 | | -| |
22 | | -*/ |
23 | | -try { |
24 | | - \Dotenv\Dotenv::createUnsafeImmutable(__DIR__)->load(); |
25 | | -} catch (\Throwable $th) { |
26 | | - trigger_error($th); |
| 3 | +/** |
| 4 | + * Leaf API - A minimal but powerful MVC API framework |
| 5 | + * |
| 6 | + * @package Leaf API |
| 7 | + * @author Michael Darko <[email protected]> |
| 8 | + */ |
| 9 | + |
| 10 | +$uri = urldecode( |
| 11 | + parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) |
| 12 | +); |
| 13 | + |
| 14 | +// This file allows us to run the app from the root of the project. |
| 15 | +// This provides a convenient way to test your Leaf MVC app |
| 16 | +// without having installed a "real" web server software here. |
| 17 | + |
| 18 | +// It also allows you to directly load up your application from |
| 19 | +// the root file for quickly hosting on shared hosting platforms. |
| 20 | +if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) { |
| 21 | + return false; |
27 | 22 | } |
28 | 23 |
|
29 | | -/* |
30 | | -|-------------------------------------------------------------------------- |
31 | | -| Attach blade view |
32 | | -|-------------------------------------------------------------------------- |
33 | | -| |
34 | | -| Since blade no longer ships with Leaf by default, we |
35 | | -| can attach blade back to Leaf so you can use Leaf MVC |
36 | | -| as you've always used it. |
37 | | -| |
38 | | -*/ |
39 | | -Leaf\View::attach(\Leaf\Blade::class); |
40 | | - |
41 | | -/* |
42 | | -|-------------------------------------------------------------------------- |
43 | | -| Initialise Config |
44 | | -|-------------------------------------------------------------------------- |
45 | | -| |
46 | | -| Pass your application configuration into your leaf app. |
47 | | -| |
48 | | -*/ |
49 | | -Leaf\Config::set(AppConfig()); |
50 | | - |
51 | | -/* |
52 | | -|-------------------------------------------------------------------------- |
53 | | -| Load application paths |
54 | | -|-------------------------------------------------------------------------- |
55 | | -| |
56 | | -| Tell Leaf MVC Core where to locate application paths |
57 | | -| |
58 | | -*/ |
59 | | -Leaf\Core::paths(PathsConfig()); |
60 | | - |
61 | | -/* |
62 | | -|-------------------------------------------------------------------------- |
63 | | -| Default fix for CORS |
64 | | -|-------------------------------------------------------------------------- |
65 | | -| |
66 | | -| This just prevents the connection client from throwing |
67 | | -| CORS errors at you. |
68 | | -| |
69 | | -*/ |
70 | | -app()->cors(CorsConfig()); |
71 | | - |
72 | | -/* |
73 | | -|-------------------------------------------------------------------------- |
74 | | -| Additional Leaf Database Config |
75 | | -|-------------------------------------------------------------------------- |
76 | | -| |
77 | | -| Load leaf database configuration |
78 | | -| |
79 | | -*/ |
80 | | -Leaf\Database::config(DatabaseConfig()); |
81 | | - |
82 | | -/* |
83 | | -|-------------------------------------------------------------------------- |
84 | | -| Route Config |
85 | | -|-------------------------------------------------------------------------- |
86 | | -| |
87 | | -| Require app routes. |
88 | | -| |
89 | | -*/ |
90 | | -require __DIR__ . "/App/Routes/index.php"; |
91 | | - |
92 | | -/* |
93 | | -|-------------------------------------------------------------------------- |
94 | | -| Run Leaf Application |
95 | | -|-------------------------------------------------------------------------- |
96 | | -| |
97 | | -| Require app routes |
98 | | -| |
99 | | -*/ |
100 | | -app()->run(); |
| 24 | +require_once __DIR__ . '/public/index.php'; |
0 commit comments