Welcome Guest, Not a member yet? Register   Sign In
How to change data from php to config file
#1

Hi,

I would like to know if it is possible to modify values saved in the default config file via the framework

The goal is to make a setup at the launch of the site for the first time.

I'm using CodeIgniter v4 and i saw that it's possible to change with the v3 with :
PHP Code:
$this->config->set_item('item_name''item_value'); 

But is there a way in the v4 ?

Thank you
Reply
#2

You could make a config template with replaceable parameters and then do a str_replace on them
when finished just move the template to the config folder.

You could also do that for the database config.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3
Thumbs Up 
(This post was last modified: 02-19-2020, 10:53 AM by Kakumi.)

(02-19-2020, 07:50 AM)InsiteFX Wrote: You could make a config template with replaceable parameters and then do a str_replace on them
when finished just move the template to the config folder.

You could also do that for the database config.

Thanks, i think i got the idea.
Like that ?

PHP Code:
$configText file_get_contents("writable/template/Config.php");
$configText str_replace("{someVar}"$userInput$configText);

file_put_contents("Config/CustomConfig.php"$configText); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB