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 https://github.com/vlucas/phpdotenv and load .env in index.php. But when I tried to get the value in .env file use like ex: getenv("DB_NAME") it returns false. Not return string value of DB_NAME.
.env
DB_HOST = localhost
DB_PORT = 3306
DB_NAME = DB
DB_USER = root
DB_PASSWORD =
index.php
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
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.