0

I have added a param in config/main.php to determine if the site is offline or not. I've tried

Yii::createWebApplication($config)->run();
if(!Yii::app()->params['enabled'])
  die;

at the bottom of index.php file. but it doesn't die. Why?

1
  • 1
    i think if you call the DIE at the end, it is too late, as the ->run() command already called the APP to run.. Commented May 7, 2014 at 10:23

1 Answer 1

2

You should use CWebApplication::CatchAllRequest in your config

Refer : http://www.yiiframework.com/doc/api/1.1/CWebApplication#catchAllRequest-detail

You can specify a controller/route to show a maintenance page by changing your config array; You can have different config file for when the site is down for maintenance; and another one for when it is live your config file should look something like

return array(
 .... 
     'catchAllRequest'=>array(
          'offline/notice'
          'otherParams'=>'value',
      ),
 ....
),

You of course need to have an offline controller and notice action plus a notice view file;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.