Women in Technology

Hear us Roar



Article:
  Building a PHP Front Controller
Subject:   ErrorDocument
Date:   2005-02-04 04:31:49
From:   spdyvkng
I haven't tried this on Apache 2.x, but in Apache 1.3.x it works wonderfully.


Don't use any php files in the document root. Set the apache configuration to use an error document which is an PHP file in an out of place way (ie. not document root or below).


Then let the error document work as the handler for the application.


It adds a layer of redirection, but it has the wonderful upside of letting you use plain media and directories for those in the system, as well as maitain a "cached" hierarchy of data by adding pre- and post-processing php scripts to html documents.


This averts the problem of adding ever more complex rewrites to take into account lots of special cases (look into eZ publish 2.x (http://ez.no) series to get an idea of what I mean; I worked for eZ and I'm not mentioning this to detract from eZ publish in anyway, just an easily accessible example).


Paul K Egell-Johnsen