Front Controller pattern
The Front Controller Pattern is a software design pattern listed in several pattern catalogs. The pattern relates to the design of web applications. It "provides a centralized entry point for handling requests."
Front controllers are often used in web applications to implement workflows. While not strictly required, it is much easier to control navigation across a set of related pages (for instance, multiple pages might be used in an online purchase) from a front controller than it is to make the individual pages responsible for navigation.
The front controller may be implemented as a Java object, or as a script in a script language like PHP, ASP, CFML or JSP that is called on every request of a web session. This script, for example an index.php, would handle all tasks that are common to the application or the framework, such as session handling, caching, and input filtering. Based on the specific request it would then instantiate further objects and call methods to handle the particular task(s) required.
The alternative to a front controller would be individual scripts like login.php and order.php that would each then satisfy the type of request. Each script would have to duplicate code or objects that are common to all tasks. But each script might also have more flexibility to implement the particular task required.
Several web-tier application frameworks implement the Front Controller pattern, among them:
- ColdBox, a ColdFusion MVC framework.
- Yii, Cake, Symfony, Kohana, CodeIgniter and Zend Framework, MVC frameworks written with PHP
- Cairngorm framework in Adobe Flex.
- Microsoft's ASP.NET MVC Framework.
- Yesod web application framework written in Haskell.
- JuniorRoute, written in C# for the .NET Framework
- Alur et al., p. 166.
See also 
- Design pattern (computer science)
- Mediator pattern *Note: the Front Controller pattern is a specialized kind of Mediator pattern.
- Alur, Deepak; John Crup, Dan Malks (2003). Core J2EE Patterns, Best Practices and Design Strategies, 2nd Ed. Sun Microsystems Press. pp. 650pp. ISBN 0-13-142246-4.
- Fowler, Martin. Patterns of Enterprise Application Architecture. pp. 560pp. ISBN 978-0-321-12742-6.
- Fowler, Martin. "Front Controller". Retrieved February 2, 2008.