|
Posted by ChrisW on 07/19/07 11:15
On Jul 18, 2:21 pm, "C." <colin.mckin...@gmail.com> wrote:
> 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.
I'm not quite sure what you mean by modelling the application
architecture on Java's. Perhaps I wasn't clear enough, I was meaning
that I use the $_GET method, so that the URL variable is showing what
page should be included. It seems a lot of websites make use of this
method, but is it a relatively bad way to do things?
This is the 1st way that I had thought to continue.
> > 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.
If I understood how to do that then I might agree it's better :) I'll
go and have a look...
> > 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');
> //
>
> }
In what ways could / would writing the data to individual static html
files add dependencies?
> What happenned to option 3?
The third way is the way that I'm currently using.
Thanks,
Chris
[Back to original message]
|