What I need to achieve is very simple logically, I use Laravel framework and need my users to be able to change few settings directly from a form rather than opening the settings file which look like this :
<?php
return array(
'driver' => 'gd'
);
So the question would be how to access a php array file based on key, an update the value ?
After getting settings with
$settings = require "settings.php";
You can populate the form and get changes submitted back. After you get ALL of the settings into $settings (not just the changed settings, all of 'em), you can write them back with
$php = "<?php return " . var_export($settings,true) . ";";
file_put_contents("settings.php", $php);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With