Maintenance mode
Sometimes, there is a need to fine tune some application settings or restore a database from a backup. When working on tasks such as these, it is not desirable to allow everyone to use the application because it can lead to losing the recent user messages or showing the application implementation details.
In this recipe, we will see how to show everyone except the developer a maintenance message.
Getting ready
Create a new yii2-app-basic
application by using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guidestart-installation.html.
How to do it...
Carry out the following steps:
- First, we need to create
protected/controllers/MaintenanceController.php
. We do this as follows:class MaintenanceController extends Controller { public function actionIndex() { $this->renderPartial("index"); } }
- Then we create a view named
views/maintenance/index.php
, as follows:<?php use yii\helpers\Html; ?>...