Page 2 of 2
Posted: Fri Sep 30, 2005 1:47 pm
by Christopher
psatish wrote:I have implemented the same after reading all the discussions. So now all my pages are channelled through index.php with a querystring showing what page to be loaded.
But I think my application design has to be more tightly OOP-ed to take advantage of such designs.
There are many discussions and examples of implementing a Front Controller in PHP. You might want to search the web for examples.
psatish wrote:MURPHY'S LAW - WHEN YOU HAVE A HAMMER IN YOUR HAND EVERYTHING LOOKS LIKE A NAIL
Actually that's not Murphy's Law, that's a proverb about narrowmindedness. Murphy's Law is: "If anything can go wrong, it will" and was about taking into account all potential points of failure when engineering something.
Posted: Fri Sep 30, 2005 10:40 pm
by psatish
arborint wrote:Actually that's not Murphy's Law, that's a proverb about narrowmindedness. Murphy's Law is: "If anything can go wrong, it will" and was about taking into account all potential points of failure when engineering something.
Yes, quite true but I remember to have read it in the Murphy's Laws series but was too lazy to actually find out who said it
Will change it though

Posted: Fri Sep 30, 2005 11:24 pm
by alvinphp
arborint wrote:There are many discussions and examples of implementing a Front Controller in PHP. You might want to search the web for examples.
I have been coding this way (Front Controller Pattern) for quite a while, but never had a name for it. I don't know if I feel smart for doing it this way or dumb for not knowing a pattern already existed for this.
Posted: Sat Oct 01, 2005 7:52 am
by Maugrim_The_Reaper
I think every PHP programmer feels that way after they work though several patterns for the first time. Your first reaction is say "DOH!" and the second to kick your shins for not researching patterns sooner...
I see nothing wrong with passing page via a query string - it's what all my own front controllers do. Generally my pages are referred to as:
index.php?action=index.display (the default page for index.php (if no querystring)) or game.php?action=fleet.attack&fid=3, etc.
In this case, the FC would delegate to the relevant Command object - i.e the Attack Command of the Fleet Module. Don't worry about that level of design though

I do it the seemingly complex way since I use FC as part of a broader pattern...
I don't use mod_rewrite on the basis it exists to make things "pretty". I see little added security unless you wish to obscure page flow to a user who has no clue about mod_rewrite. It's one of those developer preferences you sometimes see argued to death on forums...
Posted: Sun Oct 02, 2005 11:59 pm
by Christopher
psatish wrote:Yes, quite true but I remember to have read it in the Murphy's Laws series but was too lazy to actually find out who said it
They are both good advice for programmers
