Previous Up Next
Getting Started phpHtmlLib Framework MVC - Controller

Project Layout

Working with the new framework layout of phpHtmlLib.

by Walter A. Boring IV
© October 2007, Walter A. Boring IV
(phpHtmlLib 3.0.1)

Table of Contents

The new project directory layout.

Since phpHtmlLib is now an application development framework, the way you use it has been changed from the old 2.x versions.

The phl.php script automatically created a proper directory structure for you, with all of the needed directories and files needed to get an application hello world running.

Below is an example of the myproject directory structure.


The dev directory.

The project's dev directory contains some very important scripts which you should run when you make changes to your project..

  • autoload_generator.php

    This script will need to be run every time you add a new class to your project. You should only have 1 class per file. This script generates the myproject/lib/ file which contains the ClassMap of your entire project and it creates the php5 __autoload() function that will automatically deal with all of your includes.

  • dot_generator.php

    This script will connect to your database(s), get the meta data for all of your tables and generate the DataObjectTemplates for each table specified in the myproject.xml file.

    Every time you make changes to your database schema, you should run this script. This will ensure the meta data about the tables you already have converted to DataObjects will be up to date in your php code. When the DataObjects gets out of sync with the table schema, then you will start to see exceptions being thrown, so keep your DataObjectTemplates up to date.

  • myproject.xml

    This file describes for each database in your project, which tables you want the dot_generator.php script to create DataObjectTemplate classes.

  • The lib directory.

    This directory contains almost all of your project's real code. All of your page classes, FormContent childs, datalists, business objects, etc. will go inside the lib directory. Below is a short description of the lib directory files and layout..


    This file creates an uncaught exception handler, which you will eventually want to modify to not output the exceptions once you are done working on your project. I would suggest logging the exceptions to a file and outputting some 'oops' page.

    The file also creates the phphtmlib required define('PHPHTMLLIB') that points to the installed directory of phphtmllib inside your project. Don't modify this as it should be correctly pointint to external/phphtmllib.

    It includes the phphtmllib required include files, and then the project's


    This file ceates the global Config object and puts it in $GLOBALS['config']. It then sets all of the phphtmllib required config entries, such as the path to the images directory for widgets rendering properly, the file_cache_dir for storing FileCache entries and other entries which should be fairly self explanitory.

    It also creates the DB_* config entries which came from the phl.php script when it prompted you for the database connection parameters. These config settings are used inside your myprojectDB object (which lives in lib/core/db/

    Do not remove any of the generated entries from phl.php as they are required for your project to work properly. You can easily add new entries by simply setting them.

  • core directory

    This directory contains your project's 'core' classes, such as the myprojectDB database object, myprojectPage class, and various others. This directory is just a logical repository of the 'core' classes to your project that should be available project wide.

  • modules directory

    This directory is another logical repository for containing classes that are grouped together. I typically create modules like 'user' which contains classes that are associated with managing users.

  • Previous Up Next
    Getting Started phpHtmlLib Framework MVC - Controller

    Documentation generated on Thu, 11 Oct 2007 12:05:13 -0700 by phpDocumentor 1.4.0