Creating a web installer is not hard – as a matter of fact – it is downright easy. You just have to know a few things. Get the database details, create the database, save the details. That’s it!
Getting Database Details
A simple four field form will suffice. The important thing to remember is that the data must be saved as session variables – as we are using a multi-page form.
As soon as you get the DB details, try to connect to the database and confirm that the DB details is correct. If the connection attempt fails, take the user back to the DB details form. Else go to step two.
Insert Initial Data
This part is easy – just run a bunch of SQL statements to create the necessary table structure and insert the initial data.
Save the Details
This should be the last step of the installation. Just take all the data from the session variables and write it to a file, say ‘configuration.php’. Write the data as PHP code – so all you have to do to retrieve the data is include the file.
The code for the installer in the next post.
That sounds simple as it is!