Load data from exported environment variables in laravel

Viewed 41

The context is I currently working with laravel framework. Is it possible if I want to move all configs in .env file into system environment variables? so I don't need .env file anymore. So I will do:

export APP_NAME=Laravel
export APP_ENV=local
export APP_KEY=
export APP_DEBUG=true
export APP_URL=http://localhost
...

then remove the .env file. What should I do to make laravel read all configurations from exported environment variables instead of read from .env file? Thank you

1 Answers

Can't understand why you want overhead of environment variables when Laravel itself give the functionality of accessing .env variables using

env('APP_NAME')

All of the variables listed in the .env file will be loaded into the $_ENV PHP super-global when your application receives a request so alternatively you can use $_ENV['APP_NAME'] also.

Related