Skip to content

Commit e1c6d7b

Browse files
committed
feat: add new env loader
1 parent 088a14e commit e1c6d7b

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

leaf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ require __DIR__ . '/vendor/autoload.php';
3333
| Quickly use our environment variables
3434
|
3535
*/
36-
try {
37-
\Dotenv\Dotenv::createUnsafeImmutable(__DIR__)->load();
38-
} catch (\Throwable $th) {
39-
trigger_error($th);
40-
}
36+
\Leaf\Core::loadApplicationEnv(__DIR__);
4137

4238
/*
4339
|--------------------------------------------------------------------------

public/index.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
$appPath = dirname(__DIR__);
4+
35
/*
46
|--------------------------------------------------------------------------
57
| Switch to root path
@@ -9,7 +11,7 @@
911
| resolve app paths.
1012
|
1113
*/
12-
chdir(dirname(__DIR__));
14+
chdir($appPath);
1315

1416
/*
1517
|--------------------------------------------------------------------------
@@ -22,21 +24,7 @@
2224
| loading of any our classes "manually". Feels great to relax.
2325
|
2426
*/
25-
require dirname(__DIR__) . '/vendor/autoload.php';
26-
27-
/*
28-
|--------------------------------------------------------------------------
29-
| Bring in (env)
30-
|--------------------------------------------------------------------------
31-
|
32-
| Quickly use our environment variables
33-
|
34-
*/
35-
try {
36-
\Dotenv\Dotenv::createUnsafeImmutable(dirname(__DIR__))->load();
37-
} catch (\Throwable $th) {
38-
trigger_error($th);
39-
}
27+
require "$appPath/vendor/autoload.php";
4028

4129
/*
4230
|--------------------------------------------------------------------------
@@ -56,6 +44,16 @@
5644
unset($path);
5745
}
5846

47+
/*
48+
|--------------------------------------------------------------------------
49+
| Bring in (env)
50+
|--------------------------------------------------------------------------
51+
|
52+
| Load our environment variables into our application context
53+
|
54+
*/
55+
\Leaf\Core::loadApplicationEnv($appPath);
56+
5957
/*
6058
|--------------------------------------------------------------------------
6159
| Run your Leaf MVC application

0 commit comments

Comments
 (0)