:: Table of Contents ::
 
Subchapter 11.2: Polyphony: StartupCheck

The StartupCheck package in Polyphony allows you to automate, with the use of "requirement modules", the process required by most web applications to check system resources and requirements, and run autonomous (those not requiring user input) or non-autonomous updates/installations. The StartupCheck package is useful in the following areas, including others

The following sections of this manual will detail the usage of this package.

11.2.1 Basic Usage

There are two main ways to use the StartupCheck package: either in conjunction with the PHP session handler (suggested), or run every pageload. We will explain here how to use it with the session handler, as using it without is just simplifying the same process. The following code will check to make sure that the version of Harmoni we are using is at least 0.2.0, that register_globals and magic_quotes_gpc are off, and that we have the PHP extension gettext installed. The class files for these pre-installed requirements can be found in polyphony/main/library/StartupCheck/CommonRequirements.

In the above block of code, the first section first checks to see if the session variable __startupCheck has been defined, and if not, it creates a new StartupCheck object and stores it in the session. Next, it adds a number of requirements via the addRequirement() function. The first parameter is just a unique name that you assign to the requirement. The second is a class that implements the StartupRequirement interface (the file can be found in polyphony/main/library/StartupCheck/StartupRequirement.interface.php). The StartupRequirement is where all the action occurs. By changing what StartupRequirements you add to the StartupCheck class, you can control how the startup/update/install process of your program goes. The next sections will concentrate on the creation of these StartupRequirement classes.

The second section of the code above tells the StartupCheck class to go through all of the requirements and check their status, update them if necessary, and ask for user input if that's needed as well. The handleAllUpdates() method takes the Harmoni object as its paramter and returns true if everything's up-to-date or if things were updated on their own. It will return false if either something went wrong or if user input is needed. If the latter is the case, then the StartupCheck class outputs an HTML page asking for the required information, so your program should halt execution to let the user enter information.

11.2.2 StartupRequirements

The StartupRequirement interface is pretty simple. It requires that your class have only four methods

A requirement's status is described by one of the following constants: For more information on creating new StartupRequirements, take a look at the classes in the folder polyphony/main/library/StartupCheck/CommonRequirements.