laravel-dotenv-editor icon indicating copy to clipboard operation
laravel-dotenv-editor copied to clipboard

Varible changes but when called it's getting the old value instead of the new one.

Open erick-chali opened this issue 8 years ago • 1 comments

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

erick-chali avatar Dec 14 '16 03:12 erick-chali

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:

  1. include Facades config use Illuminate\Support\Facades\Config;
  2. 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([]); }

ankitkchetu avatar Feb 08 '20 09:02 ankitkchetu