2017 © Pedro Peláez
 

yii2-extension yii2-maintenance-mode

Maintenance mode component for Yii framework 2.x.x version.

image

brussens/yii2-maintenance-mode

Maintenance mode component for Yii framework 2.x.x version.

  • Saturday, January 13, 2018
  • by brussens
  • Repository
  • 8 Watchers
  • 54 Stars
  • 36,210 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 20 Forks
  • 4 Open issues
  • 8 Versions
  • 14 % Grown

The README.md

Yii2 Maintenance mode component

Latest Stable Version Total Downloads License, (*1)

Install

Either run, (*2)

php composer.phar require --prefer-dist brussens/yii2-maintenance-mode "*"

or add, (*3)

"brussens/yii2-maintenance-mode": "*"

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

Add to your config file:, (*5)

'bootstrap' => [
    'brussens\maintenance\Maintenance'
],
...
'container' => [
    'singletons' => [
        'brussens\maintenance\Maintenance' => [
            'class' => 'brussens\maintenance\Maintenance',

            // Route to action
            'route' => 'maintenance/index',

            // Filters. Read Filters for more info.
            'filters' => [
                [
                    'class' => 'brussens\maintenance\filters\RouteFilter',
                    'routes' => [
                        'debug/default/toolbar',
                        'debug/default/view',
                        'site/login',
                    ]
                ]
            ],

            // HTTP Status Code
            'statusCode' => 503,

            //Retry-After header
            'retryAfter' => 120 // or Wed, 21 Oct 2015 07:28:00 GMT for example
        ],
        'brussens\maintenance\StateInterface' => [
            'class' => 'brussens\maintenance\states\FileState',

            // optional: use different filename for controlling maintenance state:
            // 'fileName' => 'myfile.ext',

            // optional: use different directory for controlling maintenance state:
            // 'directory' => '@mypath',
        ]
    ]
]

Filters

You can use filters for allow excepts:, (*6)

'container' => [
    'singletons' => [
        'brussens\maintenance\Maintenance' => [
            'class' => 'brussens\maintenance\Maintenance',
            // Route to action
            'route' => 'maintenance/index',
            // Filters. Read Filters for more info.
            'filters' => [
                //Allowed routes filter. Your can allow debug panel routes.
                [
                    'class' => 'brussens\maintenance\filters\RouteFilter',
                    'routes' => [
                        'debug/default/toolbar',
                        'debug/default/view',
                        'site/login',
                    ]
                ],
                // Allowed roles filter
                [
                    'class' => 'brussens\maintenance\filters\RoleFilter',
                    'roles' => [
                        'administrator',
                    ]
                ],
                // Allowed IP addresses filter
                [
                    'class' => 'brussens\maintenance\filters\IpFilter',
                    'ips' => [
                        '127.0.0.1',
                    ]
                ],
                //Allowed user names
                [
                    'class' => 'brussens\maintenance\filters\UserFilter',
                    'checkedAttribute' => 'username',
                    'users' => [
                        'BrusSENS',
                    ],
                ]
            ],
        ]
    ]
]

You can create custom filter:, (*7)

class MyCustomFilter extends Filter
{
    public $time;

    /**
     * @return bool
     */
    public function isAllowed()
    {
        return (bool) $this->time > 3600;
    }
}

Set maintenance mode by console or dashboard

Add to your console or common config file:, (*8)

'container' => [
    'singletons' => [
        'brussens\maintenance\StateInterface' => [
            'class' => 'brussens\maintenance\states\FileState',
            // optional: use different filename for controlling maintenance state:
            // 'fileName' => 'myfile.ext',

            // optional: use different directory for controlling maintenance state:
            // 'directory' => '@mypath',
        ]
    ]
],
'controllerMap' => [
      'maintenance' => [
          'class' => 'brussens\maintenance\commands\MaintenanceController',
      ],
],

Now you can set mode by command:, (*9)

php yii maintenance/enable
php yii maintenance/disable

The Versions

13/01 2018

dev-master

9999999-dev

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry
by Poltoratsky Alexander
by ibra1994

maintenance yii2 yii yii 2 mode

19/06 2017

0.2.6

0.2.6.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry

maintenance yii2 yii mode

28/01 2017

0.2.5

0.2.5.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry
by Poltoratsky Alexander
by ibra1994

maintenance yii2 yii 2 mode

11/01 2017

0.2.4

0.2.4.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry
by Poltoratsky Alexander
by ibra1994

maintenance yii2 yii 2 mode

13/11 2015

0.2.3

0.2.3.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry
by Poltoratsky Alexander

maintenance yii2 yii 2 mode

26/10 2015

0.2.2

0.2.2.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

BSD-3-Clause

The Requires

 

by Brusenskiy Dmitry
by Poltoratsky Alexander

maintenance yii2 yii 2 mode

24/04 2015

v0.2.1

0.2.1.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

BSD-3-Clause

The Requires

 

by Brusenskiy Dmitry

maintenance yii2 yii 2 mode

09/02 2015

v0.2.0

0.2.0.0

Maintenance mode component for Yii framework 2.x.x version.

  Sources   Download

BSD-3-Clause

The Requires

 

by Brusenskiy Dmitry

maintenance yii2 yii 2 mode