title: Setup File .env in Slim Framework
body: <p>I'm new to slim framework. I'd try to add .env file in root folder project and then I want to access the value inside .env file. I've tried use this package <a href="https://github.com/vlucas/phpdotenv" rel="nofollow noreferrer">https://github.com/vlucas/phpdotenv</a> and load .env in index.php. But when I tried to get the value in .env file use like ex: getenv(&quot;DB_NAME&quot;) it returns false. Not return string value of DB_NAME.</p>
  <p>.env</p>
  <pre><code>DB_HOST = localhost
  DB_PORT = 3306
  DB_NAME = DB
  DB_USER = root
  DB_PASSWORD = 
  </code></pre>
  <p>index.php</p>
  <pre><code>$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
  $dotenv-&gt;load();
  </code></pre>
  <p>I use slim framework ^4.*, web server laravel valet, database MySQL. Or is there any other alternative way to configure .env in slim framework ? Thank You.</p>