when I would get a variables from .env file using env() function, always returns null. I tried cache:clear, config:cache, finally i change in correct php.ini value from variables_order = "GPCS" to variables_order = "EGPCS". From this moment returns $_ENV array of data, but not include data from .env file.
I could't get data from .env anyway. Can anyone help me?
Yes, i treid case sensitivity, but no success :( Your example is awesome, I don't know tinker before. At this moment thing seems like a .env file can't cache, but in /bootstrap/cache/config.php is a PART of .env file already cached. But from tinker i can't access any variable from .env file, like DB_HOST etc.
Laravel probably takes it from /bootstrap/cache/config.php and at command php artisan config:cache caches only PART of .env file. But again this values are not accessible from env() command :(
Hi, restarting web server (apache2) I tried many times, same sudo service apache2 reload. But no effect :( I totally don't know, how is this possible, how can Laravel cache only PART of .env file and why this variables are not accessible from env() command / function.
I tried access to .env variables in other project based on Laravel, there it works. Superglobal variable $_ENV is filled with values from .env file and varibles are accessible from env() function.
If you cache the config, you can't use env() in your application (only in config files). Use config() instead and env() only in config files (or don't cache the config).
If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null.