jc-it/yii2-maintenance-mode

Maintenance mode implementation for Yii2

Installs: 46

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.1.0 2022-09-29 07:04 UTC

This package is auto-updated.

Last update: 2024-04-29 04:59:20 UTC


README

This extension provides a maintenance mode implementation for Yii2.

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require jc-it/yii2-maintenance-mode

or add

"jc-it/yii2-maintenance-mode": "^<latest version>"

to the require section of your composer.json file.

Configuration

  • Add maintenance mode as component
...
'bootstrap' => ['maintenance'],
'components' => [
    'maintenance' => [
        'class' => \JCIT\maintenance\components\MaintenanceMode::class,
    ],
],
  • Add the console controller
class MaintenanceController extens \JCIT\maintenance\controllers\Maintenance
  • Add a Maintenance action to your SiteController (i.e.)
class SiteController extends \yii\web\Controller
{
    public function actions(): array
    {
        return [
            'maintenance' => \JCIT\maintenance\actions\Maintenance::class,
        ];      
    }
}

Usage

To enable maintenance mode, run the maintenance/enable console command with optionally a duration and message.

src/yii maintenance/enable --message "We are performing maintenance." --duration 3600

To extend the duration of the maintenance mode use the maintenance/extend console command.

src/yii maintenance/extend --duration 3600

To add an update to the maintenance mode use the maintenance/update console command.

src/yii maintenance/update --message "Maintenance update"

To disable maintenance mode, run the maintenance/disable console command.

src/yii maintenance/disable

TODO

  • Add tests

Credits