File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -451,12 +451,32 @@ public static function loadConsole($externalCommands = [])
451451 }
452452 }
453453
454+ /**
455+ * Load and force-load application env into app context
456+ * @param string $directory Application root directory
457+ * @return void
458+ */
459+ public static function loadApplicationEnv (string $ directory )
460+ {
461+ \Dotenv \Dotenv::createUnsafeImmutable ($ directory )->safeLoad ();
462+
463+ if ($ _ENV ['APP_ENV ' ] !== 'production ' ) {
464+ foreach ($ _ENV as $ key => $ value ) {
465+ putenv (assignment: $ key );
466+ unset($ _ENV [$ key ], $ _SERVER [$ key ]);
467+ }
468+
469+ \Dotenv \Dotenv::createUnsafeImmutable ($ directory )->load ();
470+ }
471+ }
472+
454473 /**
455474 * Load all application routes and run the application
475+ * @return void
456476 */
457477 public static function runApplication ()
458478 {
459- // trick process into setting Leaf up
479+ // trick process into setting Leaf up for errors, sessions, etc
460480 app ();
461481
462482 try {
You can’t perform that action at this time.
0 commit comments