laravel-dotenv-editor
laravel-dotenv-editor copied to clipboard
Varible changes but when called it's getting the old value instead of the new one.
I follow the little guide on the README file and tried to get the value by the method provided with the library
$env = new DotenvEditor();
$env->changeEnv(['VARIABLE'=>'new_value']);
return $env->getValue('VARIABLE');
and by the default method.
$env = new DotenvEditor();
$env->changeEnv(['VARIABLE'=>'new_value']);
return $env->getenv('VARIABLE');
but its not bringing the new value, instead it only recognizes the value if I restart the localhost server. Any clue with this
You need to clear the config:cache after add or update .env variable. Add below code in add and update function of EnvController located at Brotzka\DotenvEditor\Http\Controllers location:
- include Facades config use Illuminate\Support\Facades\Config;
- public function add(Request $request) { $this->env->addData( [ $request->key => $request->value, ] ); Config::set($request->key, $request->value); // update config params need to add this code return response()->json([]); }