Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

O'Reilly Network:
Building a PHP Front Controller
Jul 12, 2004 @ 12:05:47

I recently had the opportunity to implement some small (noncommercial) web sites in PHP. One of many decisions I faced concerned the templating strategy: duplicated, include()-based template pages weren't quite future-proof, while a formal, external template library would have been overkill.

Luckily, the web host in question permitted certain key Apache directives in .htaccess that let me customize request handling. Add to that PHP's OO support and my templating decision reached a comfortable middle ground in the form of a custom front controller

In Building a PHP Front Controller, as mentioned above, the author creates a base from the front controller design pattern to centralize the processing of all of the requests to his site through a single point of entry. He shows a "stripped down version" of the code, making it as lean and clean as possible. He uses a combination of Apache methods and PHP scripting (see sample code) to create a custom format for the site, routing all web requests through a "simple.php" script.

tagged:

Link:


Trending Topics: