I am developing a laravel ride sharing applicaiton and for the settings data I used a config files. To change any value usign file file_get_contents after that with str_replace and file_put_contents for updating the value. here is some code example:
$config = base_path() . '/config/constants.php';
$file = file_get_contents($config);
$change_content = $file;
foreach ($request->all() as $key => $value) {
$value = (trim($value) == 'on') ? '1' : trim($value);
$searchfor = config('constants.' . $key);
if ($value != $searchfor) {
$search_text = "'" . $key . "' => '" . $searchfor . "'";
$value_text = "'" . $key . "' => '" . $value . "'";
$change_content = str_replace($search_text, $value_text, $change_content);
}
file_put_contents($config, $change_content);
}
But the $change_content doesn't return any value in the AWS server
NOTE: This is working in my local machine also in Cpanel but in AWS ec2 not working. I am using php7.4, Nginx in Ubuntu 20.04. Same configuration for Cpanel, local, and AWS ec2.
Can anyone tell me that is there any extra configuration for str_replcae??