H
H
heIIfire2018-05-20 00:52:38
Laravel
heIIfire, 2018-05-20 00:52:38

Is it possible to always use the $_ENV array instead of env()?

env() is a function and $_ENV is an array. Therefore, the appeal to $_ENV is, in theory, much more productive. So why not always use it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zlatoslav Desyatnikov, 2018-05-20
@heIIfire

The application should not have env() or $_ENV calls at all, except for configs.
After caching configs (artisan config:cache) env() will always return an empty result.
This is done in order not to read the .env file each time the application starts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question