Skip to content

Instantly share code, notes, and snippets.

@skadimoolam
Created June 20, 2020 14:47
Show Gist options
  • Save skadimoolam/c35c461cb11a44b0b806e832efd6b8d4 to your computer and use it in GitHub Desktop.
Save skadimoolam/c35c461cb11a44b0b806e832efd6b8d4 to your computer and use it in GitHub Desktop.
A simple way to write new Laravel config file dynamically | More info at https://simplestweb.in
<?php
$rawSettings = json_decode($request->get('settings'), true);
if ($rawSettings == null) abort(500);
config(['settings' => $rawSettings]);
$text = '<?php return ' . var_export(config('settings'), true) . ';';
file_put_contents(config_path('settings.php'), $text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment