My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 28, 2008 by jeremy.wischusen
Labels: Featured, Overview
BasicOverview  
Basic overview of the system.

Overview

System Design

This system is designed to be flexible while still providing streamlined methodologies for building pages. The user has the choice of building pages using a DOM based methodology or by simple file inclusion. The rest of this page outlines the basic methodology and thought process behind the system, which of course is subject to change as the system evolves. Suggestions, thoughts and participation welcome.

Single Access Point

Several of the sites I have worked with have used a methodology where all request to the server are routed through a single page. I have decided to implement this as well. A .htaccess file is included in the site root which directs all site traffic through the index file. In order to enable request access to a directory, it must be included in he exclusion list (e.g., you have to allow access to CSS, JavaScript and Flash files, so those directories need to be in the exclusion list). While you incur the cost of the URL rewrite,this methodology has a number of benefits:

  • URLs can be made search engine friendly. Many search engines will ignore dynamic pages. By using so called 'smart URLS' we can eliminate those characters from the URL that would cause them to be ignored by search engines while maintaining the ability to pass variable via the URL.
  • Single point for configuration file inclusion. Since all requests (Ajax however is a special case, discussed later) are routed through the single access point, you can include a config file in this single point and all called pages will have access to it.

Basic Building Methodology

The system allows for two basic types of page building, inclusion based and DOM based.

DOM Based

The DOM based methodology centers around the PHP DOMDocument object. The base class for the DOM methodology in this framework is the DOMObject class located in the lib/framework package. DOMObject is a singleton so that all pages all pages are building off of the same of the DOMDocument instance avoiding the need to import nodes across multiple DOMDocument instances.

Inclusion Based

The inclusion based system works like any other file include. If there is no class name that matches the file name in the included file, it is assumed the the page was simply meant to be included and has its own processes defined for displaying content.

URL Parsing

The url is parsed into two basic parts, path and variables. A string sequence of _/ (underscore forward slash) separates the two sections.

Path

The path portion of the url is used to determine the display page (see Display Pages section on this page) in a special folder set in the config.xml referred to as the siteroot. The last portion of the path section is the name of the page to be included (e.g., /folder/subfolder/filename). If using the DOM based methodology it is also the name of the class to be instantiated, which must match the file name. If the class name does not match the file name, the file will simply be included. If the path portion of the URL is empty or / then a default page defined in config.xml is automatically included. If the file indicated in the path cannot be found, the a default page not found page is included located in the lib/ folder.

Variables

The variables section of the URL allows you to pass key value pairs using the key:value syntax. Pairs are separated by slashes (e.g., _/key:value/key:value/). These pairs are parsed into an associative array using the key as the array key and the value for the value. This array is defined in the global scope on the index page and can be access using PHP's global key word.

Auto Class Instantiation

If a class matching the file name of the page arrived at via the path portion of the URL is contained in the included file, it will be automatically instantiated and a display method will be called on that object. See Display pages section on this page for more details.

Display Pages

Each page that is reachable via a URL is considered a display page (i.e. something intended to show content. Again Ajax is a special case). Display pages can implement either of the building methods. Includes are pretty strait forward, so I will focus on the DOM method. A display page using the DOM building method must extend one of the display classes located in the lib/framework/display package or implement its own display () method as this method is automatically called by index.php when a class matching the file name is defined. There are two basic types of display pages HTML and XML. Please see the wiki pages for each of these types for more details.

Configuration File

Configuration parameters are centralized in an XML document located in the xml folder of the framework structure. This document is loaded into a PHP simpleXML object allowing for easy access to the contained parameters. See config.xml for more details.

Auto Load Function

The system makes use of PHP's __autoload function in conjunction with a recursive folder searching function that will attempt to locate any class that is instantiated without an associated include file. Again the assumption is that the file name matches the class name. The recursive search function defaults to class paths defined in config.xml, or you can pass a starting folder as a parameter. If the passed starting folder does not exists, the search begins in the current working directory.


Sign in to add a comment
Hosted by Google Code