Build an MVC Framework with PHP

by Keith Vance

By combining the power of PHP with a nice templating system such as Smarty and a powerful database such as PostgreSQL, you can cleanly isolate the viewer of your application from the data model and controller.

PHP now enables you to build robust, manageable, and beautiful enterprise web applications. The best way to do that is to divide the application into three components: model, view, and controller. In other words, you need to separate the presentation, the database, and the business logic from each other. The most common approach for achieving this design goal is to adhere to a strict Model-View-Controller (MVC) framework.

The greatest advantage to separating the application into discreet components is that you end up with software that doesn't scare fellow developers. Instead, you create an application that developers can be update, tweak, and manipulate without requiring major rewrites and aggressive re-factoring. The MVC architecture also will greatly improve your relationship with the marketing and business development departments, because they always want to make changes and with a well-designed application you can accommodate them.

The most effective way to build a PHP application based on the MVC design pattern is to leverage the power of a templating system such as Smarty for the Viewer, a PostgreSQL database as the Model, and object-oriented PHP classes as the Controller. This article demonstrates such an MVC framework by walking through the steps for building a simple newsreader called Amalgamate.

Read the entire tutorial on how to build an MVC framework with PHP on PHPBuilder.

This article was originally published on Friday Dec 18th 2009
Mobile Site | Full Site