2017 © Pedro PelĂĄez
 

yii2-extension yii2-maintenance

A database driven maintenance module for Yii2 projects

image

humanized/yii2-maintenance

A database driven maintenance module for Yii2 projects

  • Friday, January 20, 2017
  • by jeffrey.geyssens
  • Repository
  • 1 Watchers
  • 0 Stars
  • 92 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 Maintenance - README

A module for providing maintenance mode redirection for Yii2 web applications, (*1)

Installation

Install Using Composer

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

$ php composer.phar require humanized/yii2-maintenance "dev-master"

or add, (*4)

"humanized/yii2-maintenance": "dev-master"

to the require section of your composer.json file., (*5)

Configuration

Prerequisites

By default, redirection is disabled for routes set through Yii::$app->errorHandler->errorAction and Yii::$app->user->loginUrl[0], (*6)

Ensure that appropriate values are set through respective component configuration parameters., (*7)

This can be enabled by setting the whitelistLoginUrl and whitelistErrorAction to false, (*8)

Step 1

The module works by creating/dropping a file somewhere on the filesystem. To specify it's path, add an alias "@maintenance" to the the config/bootstrap file:, (*9)

Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@maintenance', dirname(dirname(__DIR__)) . '/frontent/runtime/maintenance');

Add specific aliases to different application config/bootstap files to allow maintenance-mode on different applications within the same yii project., (*10)

Step 2

The module comes with a redirecton behavior, which is triggered before a controller-action event. When attached to a controller, a 503 - Service Unavailable - HTTP exception is thrown when maintenance mode is enabled., (*11)

To call the behavior before each request of the application to be placed under maintenance, add following lines to the configuration file:, (*12)

return [
    'id' => 'application-name',
    ...
    'as beforeAction'=>[ 
      'class'=>'humanized\maintenance\components\behaviors\RedirectionBehavior',
    ]
    ...
],

For full instructions on how to configure the behavior, check the CONFIG-file., (*13)

Step 3 (Optional)

Command Line Interface

Add following lines to the console configuration file to enable the CLI:, (*14)

'modules' => [
    'maintenance' => [
        'class' => 'humanized\maintenance\Module',
    ],
],

Adding these lines allows access to the CLI provided by the module. Here, the chosen module-name is maintenance, as such the various routes will be available at maintenance/controller-id/action-id, though any module-name can be chosen., (*15)

For full instructions on how to use the command-line interface portion of this module, check the CLI-file., (*16)

Graphical User Interface

This package provides several components for building custom GUI solutions:, (*17)

First, the various controller actions for toggling maintenance mode are available in humanized\maintenance\actions.
These external actions can then be attached to the, (*18)

Add following lines to the web-application configuration file to enable the sample controller :, (*19)

'modules' => [
    'maintenance' => [
        'class' => 'humanized\maintenance\Module',
    ],
],

Adding these lines allows access to the CLI provided by the module. Here, the chosen module-name is maintenance, as such the various routes will be available at maintenance/controller-id/action-id, though any module-name can be chosen., (*20)

For full instructions on how to use the command-line interface portion of this module, check the CLI-file., (*21)

Important Note

The module conflicts with the Yii2 debug toolbar, which is enabled by default in a standard development environment. The module functions just fine, when the debug toolbar is disabled, i.e. as is the default case in a standard production environment, (*22)

The Versions

20/01 2017

dev-master

9999999-dev

A database driven maintenance module for Yii2 projects

  Sources   Download

GPL-3.0

The Requires

 

by Jeffrey Geyssens
by François-Xavier de Saint Pern

maintenance yii2 helper cli module