David David - 5 months ago 70
PHP Question

How to build in 'maintenance mode' in Codeigniter?

I'm using latest codeigniter and I need to create a flag (ideally in the config) when turned to 'true', all pages display a 'maintenance mode' message instead of executing their controller code.

What is the best/simplest practice for doing this?


Extend the CI_Controller by putting a new file in your core directory called MY_Controller.

In this file's constructor, do something like this:

public function __construct()

    if($this->config->item('maintenance_mode') == TRUE) {

Let all controllers in your app inherit from that class.