HTML and CSS Reference
In-Depth Information
Initializing the App
The first order of business for an app is to set up the environmental variables and global settings. This will let the app
know where files are located, how to connect to the database, whether to show debugging info, and other steps that
keep things running smoothly and predictably under the hood.
In your web root folder, create a new file called index.php . Inside, start by setting up the basics of the app:
* The initialization script for the app
* @author Jason Lengstorf <>
* @author Phil Leggetter <>
// Initializes environment variables
// Server path to this app (i.e. /var/www/vhosts/realtime/httpdocs/realtime)
define('APP_PATH', dirname(__FILE__));
// App folder, relative from web root (i.e. /realtime)
define('APP_FOLDER', dirname($_SERVER['SCRIPT_NAME']));
// URL path to the app (i.e. )
remove_unwanted_slashes('http://' . $_SERVER['SERVER_NAME'] . APP_FOLDER . '/')
// Server path to the system folder (for includes)
define('SYS_PATH', APP_PATH . '/system');
APP_PATH is a constant that will store the absolute path to the app on your server. This is used for PHP includes.
APP_FOLDER , on the other hand, stores the relative path from web root. It would be used for relative links or CSS
includes and asset paths. To avoid issues with the app running from a subdirectory, a trailing slash is included. We can
do this comfortably because of the call to remove_unwanted_slashes() .
APP_URI is the actual URI of the app. For example, if the app is at the web root of , APP_URI
would contain ; if the app is in a subdirectory called realtime, APP_URI would store .
APP_URI is determined in part using a function called remove_unwanted_slashes() , which has not yet been
defined. this will be added in the next section.
Finally, SYS_PATH contains the path to the system files (which is most of the MVC framework).
Search WWH ::

Custom Search