From 9d85914de43a3bbaaa50ffa27c449303a3a7afb8 Mon Sep 17 00:00:00 2001 From: Chris <7539871+paxperscientiam@users.noreply.github.com> Date: Sun, 29 Aug 2021 21:48:40 -0400 Subject: [PATCH 1/2] Showcasing how to use env() helper by invoking Dotenv\Dotenv independently of framework. --- components/support/.env | 2 ++ components/support/composer.json | 3 ++- components/support/index.php | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 components/support/.env diff --git a/components/support/.env b/components/support/.env new file mode 100644 index 0000000..a81955e --- /dev/null +++ b/components/support/.env @@ -0,0 +1,2 @@ +ENV_TEST_1=42 +ENV_TEST_2="forty-two" diff --git a/components/support/composer.json b/components/support/composer.json index 6ffcf88..a164bd0 100644 --- a/components/support/composer.json +++ b/components/support/composer.json @@ -4,6 +4,7 @@ "illuminate/support": "^8.0", "slim/psr7": "1.2.*", "slim/slim": "4.*", - "zeuxisoo/slim-whoops": "0.7.*" + "zeuxisoo/slim-whoops": "0.7.*", + "vlucas/phpdotenv": "^5.3" } } diff --git a/components/support/index.php b/components/support/index.php index cff98c6..e7c96f3 100644 --- a/components/support/index.php +++ b/components/support/index.php @@ -1,6 +1,7 @@ load(); + // Middleware $app->add(new WhoopsMiddleware(['enable' => true])); -$app->get('/', function (Request $request, Response $response) { +$app->get('/', function (Request $request, Response $response) use ($env) { // MessageBag init $messageBag = new MessageBag; @@ -117,6 +122,16 @@ $response->getBody()->write(" - $message\n"); } + $response->getBody()->write('
'); + + // Env + $response->getBody()->write('

Env

'); + $response->getBody()->write('
');
+
+    foreach ($env as $k => $v) {
+        $response->getBody()->write("{$k}: " . env($k) . "\n");
+    }
+
     return $response;
 });
 

From 355d384873bc3d5a147935e9802fc653777e9ce4 Mon Sep 17 00:00:00 2001
From: Chris <7539871+paxperscientiam@users.noreply.github.com>
Date: Mon, 30 Aug 2021 12:16:03 -0400
Subject: [PATCH 2/2] Update components/support/index.php

Co-authored-by: Matt Stauffer 
---
 components/support/index.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/support/index.php b/components/support/index.php
index e7c96f3..bcea18f 100644
--- a/components/support/index.php
+++ b/components/support/index.php
@@ -27,7 +27,7 @@
  // Instantiate App
 $app = AppFactory::create();
 
-// Intantiate, providing path to your .env file
+// Instantiate DotEnv, providing path to your .env file
 $dotenv = Dotenv\Dotenv::createImmutable('.');
 $env = $dotenv->load();