Hey everyone,
I am currently working on a PHP MVC project and I have come across an issue with loading environment variables from a .env file into the `getenv()` function. I have tried searching for a solution but couldn't find one that specifically relates to using the function in an MVC framework.
I have already created a .env file in the root directory of my project and added all the necessary environment variables. However, when I try to access these variables using `getenv()`, it returns empty values. I have also tried using `$_ENV` but to no avail.
I have double-checked the names of the variables in my .env file, and they match the ones I'm trying to access. I'm quite new to MVC frameworks and I'm not sure if I'm missing any additional steps specific to MVC.
So, if you've encountered a similar situation or have experience working with environment variables in a PHP MVC project, I would greatly appreciate any guidance or suggestions on how to properly load the environment variables into `getenv()`.
Thanks in advance for your help!

Hey,
I had a similar issue while working on my PHP MVC project and dealing with environment variables. After doing some research, I found a solution that worked well for me.
Firstly, ensure that you have the Dotenv library installed in your project. You can install it via composer by running the command `composer require vlucas/phpdotenv`.
Next, create a file called `.env` in the root directory of your project. Inside this file, add your environment variables in the format `VARIABLE_NAME=value`, each on a new line.
Then, in the entry point of your application, typically `index.php`, include the Dotenv library and load the environment variables. Here's an example:
With this setup, the environment variables from the `.env` file will be loaded into the `getenv()` function. You can now access them wherever needed in your MVC framework.
Make sure to restart your server or recompile your code for the changes to take effect.
I hope this helps! If you have any more questions or need further assistance, feel free to ask.