How to Create Installer for Website. PHP MySQL

Web page installer - database deployment

A simple way would be to store the SQL queries in PHP files and have PHP inject the prefix into the SQL and return the string.

Like, if you had a PHP file like this for each of your CREATE TABLE queries:

<?php
/** get_myTable.php **/
return <<<SQL
CREATE TABLE `{$prefix}myTable` ( ... )
SQL;
?>

You could do this in your main code:

<?php
$prefix = 'dbprefix_';

$create_queries = array();
$create_queries[] = include('get_myTable.php');
$create_queries[] = include('get_otherTable.php');

foreach($create_queries as $_query) {
mysql_query($_query) or trigger_error(mysql_error(), E_USER_WARNING);
}
?>

Create an exe Installer for a website Wamp

Investigate the WIX Installer. http://wixtoolset.org/ It's a good start creating complex MSI\EXE setup packages and install wizards on Windows that can also install other applications and files as part of your package.

What you describe seems like it would fit within WIX.

PHP Installer Script

I've made my own installer script and here are my tips.

  1. Make sure to validate that the script will run (file & db permissions)
  2. Make sure the folders/files/db structure isn't already present (if the script has run before)
  3. If that's the case, make sure to have an option to remove these files
  4. Always keep in mind that the user/script can fail everywhere and it should always be possible to start over


Related Topics



Leave a reply



Submit