|
Posted by C. on 07/18/07 13:21
On 17 Jul, 12:53, ChrisW <c.c.w...@gmail.com> wrote:
> Currently, I have the pages included like:www.site.com/index.php?p=about,www.site.com/index.php?p=contact, and also, for the book include,www.site.com/index.php?p=book&id=1
>
Sounds like your trying to model your PHP application architecture on
Java's. Possibly not the best starting point.
I fail to see any advantage in using a front controller architecture
with PHP (but if anyone can convince me otherwise...) and there are
some major drawbacks - particularly code complexity and transparency
of structure.
> 1. Use Apache rewrite to make the URLs look 'real' (e.g.http://www.alistapart.com/articles/urls/)
....hides the front controller - but wouldn't it be better to make
proper use of templates and include files to map URLs directly to
script entry points.
> 2. Sort all the current pages to be about.php, contact.php etc., and
> write a servlet-type page that actually creates real plain HTML pages
> for the information about the books, (e.g.www.site.com/books/book1.html).
Introduces unnecessary complexity and dependencies in the code. By all
means make the output cacheable - you could even get performance
improvements by running a caching reverse proxy on the same box as the
webserver. Alternatively implement the caching in your code:
(untested)
$cache_file=get_cache_file_for_url($_SERVER['PHP_SELF']);
if (cache_file_is_valid($cache_file)) {
$fh=fopen($cache_file, 'r');
fpassthru($fh);
fclose($fh);
} else {
// wrap in output buffering to create the cache file here
include_once($actual_php_page) || die('no php script here');
//
}
What happenned to option 3?
C.
[Back to original message]
|