PHP Classes

EZ PHP Maintenance Mode: Check if a site should be put in maintenance mode

Recommend this page to a friend!
  Info   View files Example   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 66 This week: 1All time: 10,322 This week: 560Up
Version License PHP version Categories
ez-maintenance 1.0.0The PHP License5PHP 5, Systems administration
Description 

Author

This package can be used to check if a site should be put in maintenance mode.

It can perform the necessary checks to determine if the current site is under maintenance mode, so applications can show a maintenance page while the situation is maintained.

The package provides several adapter classes that can perform several types of checks like looking at configuration files, environment variables, PHP constants, or other types implemented by custom adapter classes.

Picture of Roni
  Performance   Level  
Name: Roni is available for providing paid consulting. Contact Roni .
Classes: 12 packages by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 279835 in Bangladesh Bangladesh
Week rank: 106 Up2 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 6x

Example

<?php

include_once("../autoload.php");

EzMaintenance\Worker::watch('file', array('override_key' => 'hard'));

//Your normal code
echo "Welcome to our site";


Details

Easy Maintenance

Utility Library to handle site maintenance situation

Key Features

  • Easy to use
  • Highly Customizable

Installation/Usage

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

"require": {
    "xiidea/ez-maintenance": "dev-master"
}

Then, after running composer update or php composer.phar update, you can load the class using Composer's autoloading:

require 'vendor/autoload.php';

Otherwise, you can simply require the given autoload.php file:

require_once 'PATH_TO_LIBRARY/autoload.php';

Then you can just call EzMaintenance\Worker::watch() In your index.php (see the example)

Different Adapters to check maintenance mode

Use adapter to detect if we need to serve the maintenance page or not. 3 Types of adapter provided. You can also define your own adapter.

File Adapters

This is the default adapter. it checks for a specific file if exist or not. default path is down. For the following implementation you will be shown maintenance page if there is a file exists named maintenance.enable

<?php

EzMaintenance\Worker::watch('file', array(
        'path' => 'maintenance.enable'
));


Env Adapters

Using this adapter you can watch over existence of an environment variable. The maintenance page will be shown if the environment variable is present with specific value.

<?php

EzMaintenance\Worker::watch('env', array(
        'var_name' => 'APPLICATION_ENV',
        'check_value' => 'down'
));


Const Adapters

This is same ad the env adapter. Only difference is it will check for a php constant instead of environment variable.

<?php

EzMaintenance\Worker::watch('const', array(
        'var_name' => 'APPLICATION_ENV',
        'check_value' => 'down'
));

Custom Adapters

You can define your own adapter by implementing the EzMaintenance\Adapter\AdapterInterface

Common options

Following options are available to customize the behaviour of the library

interval

This option state the interval in second, the system will check for the site status with this interval. default is 5 second.

override_key

You can configure a key to override the maintenance mode. This is helpful t test your site normally while others will see maintenance page. To browse the page in maintenance mode, you just need to pass the override key as query parameter like: http://yourdomain.com/?key={override_key}

inverse

If you want to enable maintenance mode when adapter return false, you can set inverse = true.

template

You can provide the built-in template name(simple, game, clock) or path to your own template file. All the options will also be available in your template. You should echo $javascript in your template file to enable auto status check.

<?php
    echo $javascript;
?>

msg

If you are using any of the default template, you can customize the message using this option.

Contributing to Library

If you find a bug or want to add a feature to EzMaintenance, great! In order to make it easier and quicker for me to verify and merge changes in, it would be amazing if you could follow these few basic steps:

  1. Fork the project.
  2. Branch out into a new branch. git checkout -b name_of_new_feature_or_bug
  3. Make your feature addition or bug fix.
  4. Commit.
  5. Send me a pull request!

  Files folder image Files  
File Role Description
Files folder imageexample (2 files)
Files folder imageEzMaintenance (1 file, 3 directories)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  EzMaintenance  
File Role Description
Files folder imageAdapter (6 files)
Files folder imageHelper (2 files)
Files folder imageResources (1 directory)
  Plain text file Worker.php Class Class source

  Files folder image Files  /  EzMaintenance  /  Adapter  
File Role Description
  Plain text file AdapterInterface.php Class Class source
  Plain text file BaseVariableAdapter.php Class Class source
  Plain text file Constant.php Class Class source
  Plain text file Environment.php Class Class source
  Plain text file FileAdapter.php Class Class source
  Plain text file VariableAdapterInterface.php Class Class source

  Files folder image Files  /  EzMaintenance  /  Helper  
File Role Description
  Plain text file Security.php Class Class source
  Plain text file Template.php Class Class source

  Files folder image Files  /  EzMaintenance  /  Resources  
File Role Description
Files folder imagetemplates (4 files)

  Files folder image Files  /  EzMaintenance  /  Resources  /  templates  
File Role Description
  Accessible without login Plain text file clock.php Aux. Auxiliary script
  Accessible without login Plain text file game.php Aux. Auxiliary script
  Accessible without login Plain text file simple.php Aux. Auxiliary script
  Accessible without login Plain text file __script.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:66
This week:1
All time:10,322
This week:560Up