This is the env
variable in my config/app.php
'env' => env('APP_ENV', 'production'),
I changed the APP_ENV
variable to staging
from .env like the following:
APP_ENV=staging
I run php artisan config:clear
.
After that, php artisan env
returned:
Current application environment: staging
However, the App::environment()
still returns local
.
Route::get('/', function () {
dd(App::environment());
});
Any ideas? Did I miss something?
CodePudding user response:
It seems, on the application level, the environment variable is set correctly. The value should be staging
.
However, it can be overridden by your web server settings.
The current application environment detection can be overridden by defining a server-level APP_ENV environment variable.
Source: Laravel 9 Determining The Current Environment
You could check the web server settings.
E.g. with Apache server, the environment variable could be set, in files like httpd.conf
as following:
SetEnv ENVIRONMENT "local"