HTML and CSS Reference
In-Depth Information
Setting Up a Router for All Requests
The first thing that your framework needs is a script to route requests to the appropriate places. This script will
initialize any necessary configuration variables, load any additional required scripts, and determine the user's intent
(via the URL) to send requests through the proper controller.
Setting Configuration Variables
Because every installation of this app will likely have differences in configuration, you'll be setting up a configuration
file. In /system/config , create a new file called config.inc.php and insert the following:
<?php
/**
* A sample configuration file
*
* The variables below need to be filled out with environment specific data.
*
* @author Jason Lengstorf <jason@lengstorf.com>
* @author Phil Leggetter <phil@leggetter.co.uk>
*/
// Set up an array for constants
$_C = array();
//-----------------------------------------------------------------------------
// Converts the constants array into actual constants
//-----------------------------------------------------------------------------
foreach ($_C as $constant=>$value) {
define($constant, $value);
}
So far, this doesn't actually create any configuration variables, but it sets up a structure to do so. All configuration
variables will be added to the $_C array, which is run through a foreach loop at the bottom of the script to define each
variable as a constant.
Configuration variables are defined as constants because 1) they are immutable, which means they cannot be
altered during execution; and 2) they need to be in the global scope to be available to functions and classes.
Note
With the structure in place, start adding configuration variables. In this chapter, we need the following bits of
app-specific data to be stored:
Time zone for the app
Database configuration info
Whether to show debugging info
 
 
Search WWH ::




Custom Search