Take the 2-minute tour ×

I have created a custom configuration file for my custom CMS I am building using CodeIgniter. I want to have a "Configuration" page in the CMS that allows the user to save a contact email address and other variables.

I want to allow the user to set these config variables on the fly from the admin CP but I am having trouble doing so.

I found this article here: Dynamically updating config data codeigniter which asks a similar question but the answer is not exactly what I was looking for.

Is it possible to update a config file permanently on the fly from a controller? Right now my code looks like this:


    //load the initial view
    $this->data['subview'] = 'admin/setup/index';
    $this->load->view('admin/_layout_main', $this->data);

    //validate form
    if($this->form_validation->run('site_config') == TRUE) {

        $this->config->set_item('contact_email', $this->input->post('contact_email'));


but this doesn't seem to update the file at all. In fact, nothing seems to happen upon form submit.

share|improve this question
That set_item call does not persist the config item beyond the request. Why not just save the preferences to the database and set them in the config object them when your application bootstraps? –  Anthony Sterling Jun 10 '13 at 16:29
I could do it that way, I was trying to avoid saving the config items in the database and just update the file on the fly. Saving them in the database will require an extra HTTP request to get the config data, which isn't bad, I was just trying to avoid it. –  Ty Bailey Jun 10 '13 at 16:34
That's premature optimization, I doubt an extra query would break your site. You can always cache it so you have to query it just once (I usually do like this with editable site configs) –  Damien Pirsy Jun 10 '13 at 17:16
add comment

1 Answer

This is one of the design limitations I have encountered while working on my own CMS. configuration being inside the framework files. I then though of using a second database (SQLite for instance) to bootstrap extra configuration data but then faced a second limitation of CI as it doesn't support multiple databases at once. The only remaining option is to hard edit the config files themselves in a different context, a custom files or codeigniter hooks could do the job. or an installation controller (as implemented in pyro CMS)

If you would like to discuss more cms design issues let me know as I'm working on similar things.

Good luck.

share|improve this answer
Thanks for the suggestion with the hooks. I have kind of given up on this issue as I have found out it is basically not possible without heavily modifying the core of CI. If I run into more issues may I contact you for collaboration help? –  Ty Bailey Jun 11 '13 at 16:59
@TyBailey gladly, just keep in touch on twitter, g+ or facebook –  AchrafSoltani Jun 11 '13 at 17:14
add comment

Your Answer


