New Maintenance Plugin and how it fits into our Workflow

Published on 29th November, 2009 by Andrew Waters
Permalink | Category: Blog | Tags: wolf, plugin, workflow


Background

Something which I repeatedly do with new sites in Wolf (and previously in Frog) is build in some sort of sanity check for the incoming request and make a decision to display the content or redirect the user to another page.

New Maintenance Plugin and how it fits into our Workflow

Grab the Plugin

We have a workflow and it involves early development and front end markup being done offline using a local MAMP server and when we feel that the client / designer is ready to see the site for feedback, it gets published to a public server.

There is always a layout file in the site and in order to control access to an 'in-development' site, the layout file will start with something like this:

$allowed = array('127.0.0.1', '90.123.45.678');
$ip = $_SERVER['REMOTE_ADDR'];
if(in_array($ip, $allowed)) {
	// execute layout
}
else {
	// display no access
}

This makes it very easy to add new IP addresses to the $allowed array

For new domain names it is incredibly easy to set up a layout execution script and default to a holding page. The advantage of developing online is that our environment is the same as production so we don't have to spend time changing our variables / applications when we move from a local server to a public server.

If we are building on an existing site, we may set up a subdomain to show our client the work and debug environment issues, but our paths to files will still be wrong when we move into the live environment. This means we have three server environments to consider: local, testing and live.

I've always been frustrated at the time taking developing in one, pushing to the second then transferring to the third at the end of a project.

Managing the Process

Ideally, we'd have the same environment in testing and production but there are clearly too many stumbling blocks. So, I've built a new plugin to manage this process in a much more sophisticated, simple and adptable way.

It makes use of the Observer system so when a call comes in for a page (page_requested), this plugin is called into action to decide what to do. This bypasses the need to execute your checks in the layout as the page_requested observer is fired off before a route / layout is found for the page.

If your site is in maintenance mode and a page is requested, you can display some custom HTML to your user or redirect them to an internal maintenance page or even an external site (eg you may want to redirect to a subdomain).

By using redirection, we can simplify our process by swapping the development and live environment round using this plugin.

You can easily add IP addresses as well as associations with names and notes so you can see who an IP belongs to quickly.

There is even backdoor access so you can give access to individuals by telling them a key which is added to the URL. This allows you to give access to an individual and not an IP address.

Download

You can grab the sourcecode for this project here

It is always going to be the first plugin I use in a new site from now on and will stay on there until the day we launch / have maintenance work to carry out.

I hope that you find it as useful as we do...