.env file and performance |
Hello awesome developers!
I am a fullstack developer and i was developing an admin panel using vue.js + Laravel. There was this issue i faced with the .env file. When multiple ajax requests are sent to the server at once, and each request is reading a value from .env file, some requests are get failed in Laravel. As an example, in the process of response generation in my particular request, there are few occurrences of .env variable readings. I have found that in Laravel, each source code occurence for .env file in the controller is reading the .env file again and again and this causes to fail some requests sent to the server. So i am switching from Laravel to Codeignitter due to it's perfomace over Laravel. and i haven't faced the above issue yet in my developments. I need to know that does Codeignitter is also reading the .env file again and again per each occurence in the controller ? If so, What is the best practice to workaround this issue ?
Codeignitter is also reading the .env file again and again per each request.
If you don't want to do it, remove .env file and set environment variables with your web server.
(02-21-2021, 04:21 AM)kenjis Wrote: Codeignitter is also reading the .env file again and again per each request. Thanks for coming to my help kenjis! I think you have not completely understood my point. Let me expain it to you in detail.. lets suppose i have a variable values in .env MAX_LOGIN_ATTEMPTS=5 in the process of returning response:
(this can be more than twice in my project) So is the code ignitter reading the .env file twice for above request ? OR is the codeigniter reads the .env file once in the beginning of the request and keep the variables in memory until response is served?
Thank you for your explanation.
CodeIgniter reads .env only once per request. > is the codeigniter reads the .env file once in the beginning of the request and keep the variables in memory until response is served? Yes.
The .env file is read once per request to the application. And it saves the data as environment variables.
I highly doubt Laravel will do otherwise. |
Welcome Guest, Not a member yet? Register Sign In |