Welcome Guest, Not a member yet? Register   Sign In
Is it possible to chance config settings in controller?
#11

Maybe... I don't know exactly... It's simple. Just change in config file, change some var values of config. But not directly editing this file. But from doing controller.
e.g.

We got in config.php
$config['website_title'] = 'title';

And then we got settings web page with form and input Website_Title.
We type in 'Title2';

And then goes POST request to some controller with this value, and all I want is to save this what I typed in this input to config.php file, permament, exactly as I would edit this file directly.

And I am looking for easiest way to do this
Reply
#12

The absolute easiest way of doing this is by just editing the config.php by hand.

If an installer is not something you are looking for, then I would advise this as your best option.
Setting up your environment, going to the edit config controller and inputting all the required settings is in noway faster than just opening the file and doing it via your editor

It may look cool to have a UI for this, but that is also more prone to errors. If the config should ever change, your controller, form and rules would also need to change. The same goes for any installer that is available.

If simplicity is your number one priority, then do it by hand via your editor.

But that's just my opinion Smile
Reply
#13

Thank you for your opinion Smile.
Reply
#14

So it isn't possible to do with possible to do with CodeIgniter?
I have to figure it out myself how to do it?
To change "in file" one of the $config var value in app/conf/config?
Reply
#15

(06-21-2017, 08:34 AM)krystian2160 Wrote: I have to figure it out myself how to do it?

First, it sounds like you want somebody to build it for you when you say it like that.

Second, yes it is possible. If you have any understanding of programming and or scripting languages like PHP, you would know that doing this has nothing to do with the framework but all to do with your imagination. The biggest joy you can get is solving your puzzle with some nice code you yourself have written.

To do what you want to do you will need
  • A controller with a form
  • Methods that can read the config file and translate the config array to the form for editing
  • Methods to write the input back to the config file
  • Some regular expressions so you can find config items and change the values.
    Because when reading the config file into memory, all you are getting is a very large string.
    So look into string manipulation. Thus the regular expressions
Reply
#16

Thank you.

btw I didn't know, I didn't want it to sound like that xD. My english is just not that good Big Grin
Reply
#17

(06-21-2017, 11:45 AM)krystian2160 Wrote: Thank you.

btw I didn't know, I didn't want it to sound like that xD. My english is just not that good Big Grin

Normally I would be quick to ignore posts from members who seem to want it all without the hassle of doing the work themselves.

But I do get the idea that you are truly interested in learning CI and PHP. For that I would like to advise you to really start studying the basic of PHP, HTML, CSS and JavaScript. And please read the CI documentation. One of THE reasons I love CI is because it is so clear in it's explanation. A frameworks documentation just can't get any better than this. If you have a basic understanding of PHP then it really is a piece of cake to follow.

For the problem at hand. If you have some patients, I am in the process of developing a CodeIgniter 3 installer which has a UI for config editing, database setup and email configuration. All of which can have separate configurations for development, testing and production environments. It is about 70% done. Hope to have the first version finished within the next week or so.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB