0

Hi I use Spatie's backup package to backup database to Dropbox. I put dropbox secret info directly to .env as below code.

DROPBOX_SECRET=xxxxxxxxxx
DROPBOX_TOKEN=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

That's not comfortable once need to change these key. So, Is it possible to get key form database(Model) and put to .env via some method in controller?.

Thanks for all answers.

Chaiwat Jo
  • 133
  • 4
  • 15
  • maybe in provider, so it reads it every request. or fetch it from the database before calling the corresponding method that uses drop box and put it in environment variable. either way works fine. to put it in environment variables just `putenv("DROPBOX_SECRET=".$dropbox_secret); putenv("DROPBOX_TOKEN=".$dropbox_token);` – Ahmed Nour Jamal El-Din Dec 26 '18 at 04:09
  • I directly put ==> putenv("DROPBOX_SECRET=".$mykey); <== to controller but value not changed. – Chaiwat Jo Dec 26 '18 at 05:41
  • 1
    May this help you => https://stackoverflow.com/questions/32307426/how-to-change-variables-in-the-env-file-dynamically-in-laravel – Vijay Sankhat Dec 26 '18 at 06:21
  • Which controller?? Please provide more details about your code – Ahmed Nour Jamal El-Din Dec 26 '18 at 06:30
  • Possible duplicate of [How to change variables in the .env file dynamically in Laravel?](https://stackoverflow.com/questions/32307426/how-to-change-variables-in-the-env-file-dynamically-in-laravel) – Styx Dec 26 '18 at 10:21

0 Answers0