-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laravel recipe shouldn't have shared file .env #527
Comments
Can you make PR for it? |
Of course, will do it somewhere today |
Ok PR is there. I noticed that there was a |
I disagree with this. I think in most environments (except prod) it's helpful to automatically have a shared .env. In production you should just not create the .env file, so it won't be shared. |
I rather explicit define on which environments I want to use dotenv, than doing it implicit. |
In a lot of cases, you can't modified environments (sharing host). |
You're right on the shared hosting part, I was actually a bit surprised to see .env files on the servers because I only use it for development environments all private configuration on staging/production is done in the environment itself, and I'm not really used anymore to shared hosting to be honest. It's simply solved by adding The only reason I don't want the .env file is because I don't want others to think they can use that .env file to fix some mis configuration on staging or whatever it's cleaner to don't have it when not used. |
How you can do |
@badconker You can set your environment variables in one of the following files Or you can do it manually with |
@SanderSander Ok but these variables are only accessible from terminal no ? So you define your environment variables twice ? One time for php from webserver and one time for php from command line ? I can't use /etc/environment because i need different variables for each virtual host. |
@badconker Using Other option, use |
What do you suggest in the case where there are multiple Laravel applications running on the same server? For web requests, I could set them in each application's Let's say that both application require ten different environment variables to be set (DB_NAME, DB_PASS etc). How do I run Any ideas? |
@philbates35 Every laravel application could have a separated user, every user has his own environment variables. So if you want to run an artisan command for your 7th application you just switch to user laravel-app7 and do your things. Apparently using .env on production for laravel applications is an acceptable way of getting things done, so i would suggest using it if it doesn't really matter. |
So you confirm : if we don't want use .env file, we must declare variables twice ? (one in user environnement and one in apache/NGINX configuration file ? We can't get user environnement variables from PHP, no ?) |
No, you only need to set it in your Apache virtualhost config or for nginx I usually set it in the php-fpm config. |
A bit late reply, but you should cache your configuration. Imho you should still share the |
In the laravel recipe the
.env
file is defined as shared file on any environment and therefor is always there while it shouldn't! Dotenv loads the environment variables from.env
into $_ENV, $_SERVER but i guess the most of the time the .env is just a empty file and hopefully not used on production environmentsAlso from the documentation Usage notes of dotenv
https://github.com/vlucas/phpdotenv#usage-notes
phpdotenv is made for development environments, and generally should not be used in production. In production, the actual environment variables should be set so that there is no overhead of loading the .env file on each request. This can be achieved via an automated deployment process with tools like Vagrant, chef, or Puppet, or can be set manually with cloud hosts like Pagodabox and Heroku.
The text was updated successfully, but these errors were encountered: