config('app.env') always returns local on Ravel 9

Asked 1 years ago, Updated 1 years ago, 376 views

I'm trying to use config('app.env') to make a decision to run only when local in Ravel 9.
However, it doesn't work.
No matter how you configure .env, it always returns local.

Other files, such as .env.test, do not exist
.env.example is set to APP_ENV=local_example

Tried

  • clearing cachesailartisan config:clear
    Verify that the cache file does not exist bootstrap/cache/config.php

  • Test APP_ENV in config/app.php by changing it to APP_NAME
    'env'=>env('APP_ENV', 'production'),
    'env'=>env('APP_NAME', 'production', Resultslarvel9local and .env Content Display

  • Verify that the test is set to .env APP_ENV in sail artisan env

  • .env contains only one APP_ENV designation

  • Removed APP_ENV from

    .envOutput results local

  • Holds APP_ENV when you stop and start sail.Don't keep APP_NAME, etc. and the value changes immediately after you change it

Clearing the Cache sail artisan config:clear
Verify that the cache file does not exist bootstrap/cache/config.php

Test APP_ENV in config/app.php to APP_NAME
'env'=>env('APP_ENV', 'production'),
'env'=>env('APP_NAME', 'production', Resultslarvel9local and .env Content Display

Verify that the test is set to .env APP_ENV in sail artisan env

There is only one APP_ENV designation in .env

Removed APP_ENV from .env.Output results local

Retains APP_ENV at "start" when stopping and starting sail.Don't keep APP_NAME, etc. and the value changes immediately after you change it

Question

Why can you retrieve other .env values correctly?
I don't know if only APP_ENV always returns local

I would appreciate it if you could tell me the cause, the solution, and the possibility.
Thank you for your cooperation.

laravel

2022-12-10 05:17

1 Answers

App:environment()

Can I get an environment name in ?


2022-12-10 07:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.