0

I have to .env files .env.local and .env.pro and I don't know how to switch between files, I tried changing config\app.php from

'env' => env('APP_ENV', 'pro'),

to

'env' => env('APP_ENV', 'local'),

But I get a blank screen with no errors, How to tell the framework which file has to load?

Masoud Bimmar
  • 6,941
  • 4
  • 30
  • 33
afccc
  • 89
  • 1
  • 7
  • 1
    I think if you set the APP_ENV in the `.env` file it will try to load the `.env.{env}` file with additional values which will overwrite the ones set in `.env` – vuryss Mar 03 '20 at 15:41
  • The reason you are having a blank page is probably because you have no file that are only ```.env```, try changing ```.env.local``` to ```.env```. Your local app should start again. – Elie Morin Mar 03 '20 at 17:02
  • What you did in the ```config\app.php ``` is changing the default ```env``` value. It's a fallback in case your application can't find ```APP_ENV``` into your ```.env``` file. Now, why you want to perform env change within your app? The purpose of dotenv is to keep credential out of the code and out of subversion tools. Is your environment dynamically changing? – Elie Morin Mar 03 '20 at 17:19

1 Answers1

0

The .env file should not be replicated from your DEV environment to your production environment, so you have different versions of these files in each environment.

https://laravel.com/docs/7.x/configuration#environment-configuration

If you're using git for version control the .env file is excluded by default. However, if you need to give hints to other developers about specific configurations needed you should can put them into the .env.example file. For testing you may as described in the article in the Laravel documentation use a specific .env file, ie.: .env.testing

Edwin Krause
  • 1,766
  • 1
  • 16
  • 33