Home > Software design >  .env can't get read from inside a job
.env can't get read from inside a job

Time:02-01

I have a Laravel project (v8.12) running on PHP 7.4.3 in a dedicated AWS instance with Ubuntu 20.04. When I try to read an environment variable from inside a job, the value is always null, but it works elsewhere. I tried to switch from supervisord to sync driver, still couldn't reach it.

CodePudding user response:

Your problem could be from cache . you can below commands for remove cache .

php artisan cache:clear

php artisan config:clear 

php artisan view:clear 

CodePudding user response:

Run below commands

 composer dump-autoload

 php artisan clear-compiled
 php artisan optimize

 php artisan route:clear
 php artisan view:clear

 php artisan cache:clear
 php artisan config:cache
 php artisan config:clear

For Example

In your env file

 SITE_NAME="My website"

Get your env variable like

 $data = env('SITE_NAME');   
 echo $data;
  •  Tags:  
  • Related