Front Controller
Moderator: General Moderators
Front Controller
Can someone please help explain the best way to approach a Front Controller? How would one set up multiple MySQL queries in the simplest manner?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
that was exactly what I was thinking... what does a front controller have to do with mysql queries??arborint wrote:It is not clear how implementing a Front Controller and setting up multiple MySQL queries are related from your questions. Those are usually highly separated parts of an application. Can you clarify?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
no... a front controller simply presents a central point of access for all incoming requests... so all requests are handled in the same manner by the same set of code.psurrena wrote:I'm asking because the idea of a front controller is new to me. So you're telling me a front controller is only for templating purposes which generally would have nothing to do with MySQL queries, right?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Not for templating purposes and it does not store anything. A Front Controller centralizes the request from the browser is sent to a single script that sorts out what to do with it (based on pre-defined parameters). Probably the most confusing thing about implementing the Front Controller is that it is it is a solution to a problem with another pattern -- the Page Controller. Most patterns are solutions to problems and if you don't have the problem you don't need the pattern. The are not very helpful in isolation.
Most PHP sites use the Page Controller pattern and implement multiple PHP scripts, each as an entry point for the application. The problem occurs that as the app gets bigger or more complex you can get lots of duplicated code unless you are very disciplined. The Front Controller pattern help reduce the amount of duplicated code by providing discipline through the sturcture it provides.
Most PHP sites use the Page Controller pattern and implement multiple PHP scripts, each as an entry point for the application. The problem occurs that as the app gets bigger or more complex you can get lots of duplicated code unless you are very disciplined. The Front Controller pattern help reduce the amount of duplicated code by providing discipline through the sturcture it provides.
(#10850)
Generally if you see an application which you never leave the index page:
http://www.someapplicationsite.com/inde ... tuff&id=23
That application has implemented a front controller... you never enter the application from any other point... just index.php... but your request can change... you can change the action, params, and id... and this will be handled by the front controller.
http://www.someapplicationsite.com/inde ... tuff&id=23
That application has implemented a front controller... you never enter the application from any other point... just index.php... but your request can change... you can change the action, params, and id... and this will be handled by the front controller.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
I found Understanding MVC in PHP useful when I started looking at this subject.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA