CakePHP Maintenance Mode is to put your website in maintenance mode while you do your upgrade. Most ppl would add a static file on the server and route all request to it during maintenance. The file is shown to everybody including you unless a rewrite rule or expressions is added to exclude yourself which would complicate the matter.
This filter file would tell CakePHP to put all requests to maintenance mode i.e show a msg but would allow requests from your IPs to be processed normally.
##Requirement CakePHP 2.*
[Using Composer]
View on Packagist, and copy
the JSON snippet for the latest version into your project's composer.json
. Eg, v. 1.2.0 would look like this:
{
"require": {
"awebdeveloper/cakephp-maintenance-mode": "1.2.0"
}
}
Because this plugin has the type cakephp-plugin
set in it's own composer.json
, composer knows to install it inside your /Plugin
directory, rather than in the usual vendor directory.
It is recommended that you add /Plugin/MaintenanceMode
to your .gitignore file. (Why? Read this.)
[Manual]
- Download this: http://github.com/awebdeveloper/cakephp-maintenance-mode/zipball/master
- Unzip that download.
- Copy the resulting folder to
app/Plugin
- Rename the folder you just copied to
MaintenanceMode
[GIT Submodule]
In your app directory type:
git submodule add -b master git://github.com/awebdeveloper/cakephp-maintenance-mode.git Plugin/MaintenanceMode
git submodule init
git submodule update
[GIT Clone]
In your Plugin
directory type:
git clone -b master git://github.com/awebdeveloper/cakephp-maintenance-mode.git MaintenanceMode
In your Bootstrap.php add
Configure::write('MaintenanceMode', array(
'enabled' => true,
'view' => array(
'layout' => '',
'template' => 'MaintenanceMode/index'
),
'ip_filters' => array('127.0.*.*')
));
Also in the same file find the below code and add this line
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher',
'MaintenanceMode.MaintenanceMode' ## this line
));
It supports Following Parameters
-
enabled set this to true to enable it
-
view this is a array that accepts the template and the layout. If layout key is absent it will use the default layout.
'view' => array( 'template' => 'Pages/index' ),
or
'view' => array( 'layout' => 'main', 'template' => 'MaintenanceMode/index' ),
-
ip_filters this is either a string containing a single IP or an array containing multiple IPs for which maintainance mode will NOT be applied.
'ip_filters' => array('127.0.*.*','201.201.201.1')
or
'ip_filters' => '201.201.201.1'
For info read the docs on dispatch filter
http://book.cakephp.org/2.0/en/development/dispatch-filters.html