2

Is there any way , to overload few environment variables dynamically, i tried to overload in controller constructor which works fine , but in some cases when variables are loaded via config/services.php it does not seems to get the values which i overloaded in the controller, i suspect that the sevices.php is being called prior to controller constructor method, is there any valid way to load them dynamically on start of the app .

Don't want to do it via file instead run time.

dip1232001
  • 240
  • 3
  • 10
  • why do you not want to change them in the file? These are **constant** values. If you want other global variable just create them separately. –  Oct 13 '16 at 16:05
  • Cause there's multiple domain scenario and each domain have some specific settings which needed to be loaded dynamically. – dip1232001 Oct 13 '16 at 16:22
  • Here's how I figured out how to override env variables in Laravel Dusk https://stackoverflow.com/a/58473993/470749 – Ryan Oct 20 '19 at 14:30

1 Answers1

1

To set configuration values at runtime, pass an array to the config helper:

config(['app.timezone' => 'America/Chicago']);

https://laravel.com/docs/5.3/configuration#accessing-configuration-values

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279