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

Logemann.org:
Why Use Template Engines?
Jul 01, 2005 @ 11:29:47

From Logemann.org today there's this piece on templating in PHP and why using them can help with the creation of an MVC framework.

Generally a template engine is the best way to achieve a MVC style application. MVC means Model / View / Controller and means an architecture where basic parts of an application are seperated into different "components" or "units". For a web-application it means the following:

  • Core business logic or db-access logic normally shipped as classes in java or functions in php is called Model.
  • The look and feel of your application, how pages are layouted or roughly what comes out of your application is called the View. In our web context it is HTML, but it can be also WML or XML.
  • Session Tracking, loggin, request management or business logic calls are the responsibility for the controller. In php this will be the work for a normal php script, in java this will be done by a servlet.

He continues on giving an example of templating in PHP - using Smarty. It's a pretty simple example, but you get the idea on how templates help separate out the presentation logic from the business logic (one of the keys of MVC).

tagged:

Link:


Trending Topics: