eXtension Templates for PHP (XTP for short)
What is this? - Template engine for PHP
eXtension templates are designed to allow you to easily overcome the biggest shortcoming of PHP. Using this small library you can develop simple web applications in no time and it will allow you to break big applications into smaller pieces that are very easy to maintain.
To better illustrate use of XTP we can look how Softwarehood.com website can be divided into separate components (image on the left, every component has different background color). By this decomposition we get several more reusable pieces instead of one huge HTML.
When decomposing page into components it is very important to find the right ratio - if you create too small components you may end up with page consisting of hundreds of components making it actually harder to maintain than the original (undivided) page.
Component layout & execution model for XTP
As you can see from schema above XTP is designed with idea of separating presentation (HTML) from application logic (PHP), as well as separating web designer from developer. With XTP HTML is put into separate (.phpx) files, while PHP is kept in normal (.php) code files. Further, in order to increase reusability of code, certain often repeating parts of web pages can be put into separate packages called web components or web controls.
Every web component consist of one .phpx file with its containing HTML inside and one .php file containing logic to govern that component (please note that if component contains simple static HTML code then there is no need for .php file). One web component can include multiple other web components in its implementation.
| Next » Connecting code and template |
