brussens / Yii2 Maintenance Mode
Licence: mit
Maintenance mode extension for Yii framework 2.0
Stars: ✭ 69
Labels
Projects that are alternatives of or similar to Yii2 Maintenance Mode
Yii2 Lifecycle Behavior
Define the lifecycle of a model by defining allowed status changes.
Stars: ✭ 47 (-31.88%)
Mutual labels: yii2-extension
Yii2 Psr Log Target
Yii 2.0 log target that is able to write messages to PSR-3 compatible logger
Stars: ✭ 58 (-15.94%)
Mutual labels: yii2-extension
Yii2 User
[ABANDONED] Flexible user registration and authentication module for Yii2
Stars: ✭ 946 (+1271.01%)
Mutual labels: yii2-extension
Yii2 Social Share
With this extension you can share data from your web pages to any social network!
Stars: ✭ 48 (-30.43%)
Mutual labels: yii2-extension
Yii2 C3 Chart
Yii2 wrapper for D3-based reusable chart library
Stars: ✭ 9 (-86.96%)
Mutual labels: yii2-extension
Yii2 Jwt
JWT implementation for Yii2 Authorization process
Stars: ✭ 61 (-11.59%)
Mutual labels: yii2-extension
Yii2 Relation Trait
Yii 2 Models add functionality for load with relation, & transactional save with relation PLUS soft delete/restore feature
Stars: ✭ 47 (-31.88%)
Mutual labels: yii2-extension
Yii2 Many To Many
Implementation of Many-to-many relationship for Yii 2 framework
Stars: ✭ 30 (-56.52%)
Mutual labels: yii2-extension
Yii2 Json Editor
JSON editor widget (josdejong/jsoneditor) for Yii 2.
Stars: ✭ 11 (-84.06%)
Mutual labels: yii2-extension
Yii2 Editable
Editable widget and column for gridview.
Stars: ✭ 47 (-31.88%)
Mutual labels: yii2-extension
Yii2 Datatables
Yii2 Widget for DataTables jQuery plug-in
Stars: ✭ 67 (-2.9%)
Mutual labels: yii2-extension
Config
Yii2 application runtime configuration support
Stars: ✭ 54 (-21.74%)
Mutual labels: yii2-extension
Yii2 Maintenance mode component
Install
Either run
php composer.phar require --prefer-dist brussens/yii2-maintenance-mode "*"
or add
"brussens/yii2-maintenance-mode": "*"
to the require section of your composer.json
file.
Add to your config file:
'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:
'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:
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:
'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:
php yii maintenance/enable
php yii maintenance/disable
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].