Simple PHP Framework Overview

Seeing as how the Simple PHP Framework is . . . a framework . . . there's really not much to install. However, there are a few options you need to set and a database table you can (optionally) install. I know this looks like a lot of text to read, but trust me. It'll take less than five minutes to read and complete the instructions below. You'll have a working site and a clear understanding of how everything is setup. It's worth it! Let's start with setting up your config options.

master.inc.php

The file /includes/master.inc.php is where most of the Framework's configuration options are set. It's also the starting point for your website. i.e. most of the pages you build will include it before doing any other work.

Server Names

The first thing you need to set are your server names. These three arrays ($local_servers, $staging_servers, and $production_servers) allow you to have different settings (a different database connection for example) based on where you code is running. This is useful for when you build and test your site locally and then upload it to a staging or production server. So, open up /includes/master.inc.php and edit them to reflect the server names you are using.

For example, if you are testing your code locally at http://yoursite.dev and then uploading it to http://www.yourwebsite.com your server arrays should look like this:

$local_servers      = array("yoursite.dev");
$staging_servers    = array();
$production_servers = array("www.yourwebsite.com", "yourwebsite.com");

Note that you can leave any of the arrays empty or fill them up with as many server names as you want. It just depends on how your site is setup.

Database Settings

Directly below the server name arrays is a large if statement that tests to see which server you're currently running on and then picks the appropriate settings. Setup your database name, hostname, and login info here.

You can also customize your website's root directory and error reporting settings here. Note that the local server has error reporting turned on, while the production server has it turned off (for security purposes). Feel free to add your own configuration options into this code block.

Include Files

A little further down you'll see two include files: /includes/functions.inc.php and /includes/class.objects.php. These are important - that's why they're included in master.inc.php. The first file contains many useful utility functions as well as __autoload(), which loads in all the other include files as needed. The second file loads all of your DBObject subclasses.

Use this space to include any other files that are needed globally.

User Authentication

master.inc.php creates a new Auth object. This contains the currently authenticated user (or guest). As a security precaution, set AUTH_SALT to a random string of characters unique to your project. This is used by the Auth class to seed the hashing functions which helps to protect your users' passwords from rainbow attacks.

Note that the Auth class is designed to operate using plain text or hashed passwords. By default, to make testing easier, hashed passwords are turned off. However, once your site goes live, we strongly reccomend that you hash your passwords so they're not stored as plain text in the database. You can enable hashed passwords by setting $useHash to true in /includes/class.auth.php.

You'll also want to import this SQL file. It installs the user table which Auth needs to operate.

All Done

See, that wasn't too bad, was it? Now that you've setup master.inc.php you might want to checkout our quick and dirty installer script. It's not really an installer. It's just a quick way to create user accounts and generate your DBObject subclasses.