janedoe
janedoe

Reputation: 957

Why are Lumen environment variables out of date (or mismatched?)

So for some reason my lumen .env variables, when echoed out on the backend, don't match what I have in the actual file.

for instance, APP_DEBUG is set to true in the file but when I echo it out I get false or null. Also, if I try to change the APP_NAME nothing happens, it echoes out an outdated value.

I have tried running php artisan cache:clear but that doesn't seem to work either. For what it's worth I'm running this in a docker environment, not sure if that would affect things. Also I'm running php 7.3 with Lumen 6.0.

Upvotes: 0

Views: 710

Answers (2)

janedoe
janedoe

Reputation: 957

Well, the issue was indeed docker related.

It turns out that our environment has all .env related properties defined in the docker-compose.yml file, which was overwriting stuff. so I just had to change this:

environment:
  <<: *environment
  APP_NAME: <old value>
  APP_URL: http://auth.172.17.0.1.nip.io

and add APP_DEBUG to it as well as modify APP_NAME. So if anyone else runs into this and you're using docker, make sure that docker isn't overwriting the env properties.

Upvotes: 1

Chin Leung
Chin Leung

Reputation: 14941

You need to run php artisan config:clear to flush the cache of the configuration files.

The command php artisan cache:clear is to flush the cache of the application.

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.

For more information: https://laravel.com/docs/6.x/configuration#configuration-caching

Upvotes: 1

Related Questions