if you are using php-fpm, it should be restarted
Laravel caching and retrieving wrong value from env
I've just changed my APP_ENV to local (from production) in my .env file, and no matter what I try, Laravel keeps saying my application is in production. I've ran config:clear, cache:clear, optimize:clear, even removed my cache folder, nothing works.
Even when I comment everything in my .env file, when I run php artisan tinker, then env('APP_ENV'), the output is production. So somehow, Laravel is reading this from another place even after clearing all cache?
If I uncomment everything again and try to read any other env variable, such as DB_HOST, APP_NAME, then I get the correct values in tinker.
When I run config:cache, env gets set to production aswell in bootstrap/cache/config.php, instead of local.
Found the issue. Since I'm using docker-compose, I conditionally install xdebug depending on the APP_ENV value when building my php container. So I pass my APP_ENV to my php dockerfile as an argument:
ARG APP_ENV
ENV APP_ENV=$APP_ENV
...
RUN if [ $APP_ENV = "local" ] ; then \
# Xdebug
pecl install xdebug-3.0.2 \
&& docker-php-ext-enable xdebug \
fi
After removing ENV APP_ENV=$APP_ENV from my Dockerfile, I was able to fix this issue. Just having ARG APP_ENV in my Dockerfile was enough to pass my env value to docker.
Please or to participate in this conversation.