In your route, where key is the key, and value will be the new env value
Route::get('changeenv/{key?}/{value?}',"controller@methodname");
In your controller
public function changeEnv($key, $value)
{
$path = app()->environmentFilePath();
$escaped = preg_quote('=' . env($key), '/');
file_put_contents($path, preg_replace(
"/^{$key}{$escaped}/m",
"{$key}={$value}",
file_get_contents($path)
));
return "env change successfully " . env($key);
}
In your browser, you could type this to change the .env's CAPTCHA value
https://mysite.com/changeenv/CAPTCHA/new_value
0 comments:
Post a Comment