### Introduction to the Installer

The installer provides a wizard interface with Next and Previous buttons for performing configuration tasks. Internally, it uses a state engine to drive the screens. Each state is given a step id. You can find out more in "Theory of Operation" below.

The installer uses the following core code files:

    	index.php:            Run installer from this script
    	installer.inc.php:    Base class for all installations
    	steps.inc.php:        Code for specific steps in the install process

And the following configuration files:

    	config.inc.php:       Configuration settings
    	installer-*.inc.php:  Language files
    	src.config.inc.php:   Template for configuration file to be generated

Additional files used include:

    	testzo.enc.php:       Encoded file to test for existance of Zend Optimizer
    	testzo.inc.php:       Source of above file
    	installer-*.inc.php:  Language files

### Theory of Operation

We have a base class, Lens_Wizard_Base, in installer.inc.php. Lens_Wizard_Base provides the base functionality for all installations. THe actual code for a specific installer is the derived class Lens_Wizard, in steps.inc.php. This Lens_Wizard is called from index.php.

All functions in the class receive as a parameter the $wz variable. This is an array which is also a session variable. You should use $wz to store session/state/configuration information. The $wz variable will also hold all language strings that you define in the language file.

Each screen in the wizard is given an step id, starting with 0 for the first id. You can see the current step on the lower-left corner of the form. The last step id has to be defined also, in $LENSWZ['LASTSTEP'] in the config.inc.php file.

Each step also maps to a RenderN method of the Lens_Wizard class, so step 0 is rendered (generated) by Render0, step 10 by Render10. Similarly, in the language files, each step has a default text description that it will display, e.g. $LENSWIZ_LANG['0'] for step 0, $LENSWIZ_LANG['10'] for step 10.

Moving from step to step is controlled by Next($step,&$wz) which calls _Next($step,&$wz,$request). You need to write your own version of the _Next() method. _Next() is passed the current step id in $step, and you should return the next step to display.

HTTP GET and POST variables are passed to the _Next() function in the $request array (so you don't have to worry whether it is a POST or GET). You should process these variables and modify $wz as appropriate to store state information.

Similarly, the previous step is controlled by Prev().

If the user can go no further because there was an error in the configuration, you can hide the Next button by setting $this->noNext = true in your RenderN() or _Next() function.

### Configuration

You will need to configure the following items in config.inc.php:

    // TITLE TO DISPLAY
    $LENS_PROD = 'Demo Installer';

    // FINAL STEP ID
    $LENSWZ['LASTSTEP'] = 6;

    // TEST FOR ZEND OPTIMIZER INSTALLED
    $LENS_TEST_ZEND_OPTIMIZER = true;

    // TEST FOR MAGIC QUOTES OFF
    $LENS_MAGIC_QUOTES_OFF = false;

    // MINIMUM PHP VERSION REQUIRED
    $LENS_MIN_VERSION = '4.0.6';

    // LANGUAGE
    $LENSWZ_LANG = 'en';

    // CHECK TO SEE IF THIS TABLE EXISTS IN DATABASE,
    // TO CONFIRM TABLES CORRECTLY INSTALLED.
    // SHOULD PROBABLY CHOOSE LAST TABLE TO BE CREATED
    $LENSWZ_TABLE_CHECK = 'PHPLENS';

    // List of database drivers you support...
    $LENS_DRIVERS = array(
    	'access' => 'Microsoft Access',
    	'db2' => 'DB2',
    	'odbc' => 'ODBC',
    	'informix' => 'Informix',
    	'ibase' => 'Interbase/Firebird',
    	'mssqlpo' => 'Microsoft SQL Server 7 or later',
    	'mysql' => 'MySQL (Isam)',
    	'mysqlt' => 'MySQL(InnoDB)',
    	'oci8' => 'Oracle 8i or later',
    	'postgres7'=>'PostgreSQL 7 or later',
    	'sybase' => 'Sybase'
    	);

If you need to localize your installer languages, setup the language strings in the language files.

Then in the _Next() function, determine your screen logic (going to which step from the current step) and store POST and GET variables you need in the $wz session variable.

Define the appropriate steps to go to by coding the RenderN() functions. If you are using the default DEMO steps.inc.php, then you will probably need to modify Render4(), which defines the CREATE SQL statements, and Render6() which generates the PHP configuration file.

Finally, if you need to generate a PHP configuration file, we provide you with a template to do so in src.config.inc.php. We use a simple search and replace algorithm to replace the tags, that look like this: {TAG}.