There are many template engines / frameworks for PHP out there. To name a few:
- Zend Framework - http://framework.zend.com
- Code Ignigter - http://www.codeignigter.com
- Cake PHP - http://www.cakephp.org
- Smarty -http://smarty.php.net
- PEAR - http://pear.php.net
and I believe many more.
Which are the most popular / best to use, being both lightweight and easy to learn? I understand that much of it comes down to your own preference, but in generally speaking I'd like some opinions on which one to use, as I feel overwhelmed by the amount of engines available.
Is there an online comparison on the different frameworks?
The Template Engine Hype? Which one?
Moderator: General Moderators
The Template Engine Hype? Which one?
Last edited by josamoto on Mon Sep 10, 2007 4:26 am, edited 1 time in total.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I need a MVC sort of thing, but not something with a million-and-one classes. Also looking at the URL parsing abilities of CodeIgniter, as well as functions for making my everyday tasks in PHP easier and have development go much quicker. CodeIgniter has shorthand tags for PHP for example you can use <:=funkyChicken?>. I basically want JSP custom tags, but in PHP.
My main interest is in separating my application logic from my template / user-interface, i.e. MVC (Model + View + Controller). A lot of the code we develop gets reused a lot, as we develop websites for estate agents. Currently all 300 sites have a copy of it's own application logic. So if a bug appears, we have to fix it in 300 instances of code.
I want to revamp the code so its all central with also a central database, but each agent has their own website template, which draws information related to their site from the central database using centralized code. One instance of code will make the project easier and allow us to create a portal as well as maintain the code, supply bug fixes and develop add-ons across the board. Also one database is used across multiple agents where their data is separated by means of a unique agent ID.
Basically I need a RAD strategy, and at current, CodeIgniter looks the best for me. PEAR and Zend Framework are too expansive, I do suppose it has been around for a while so more code has been developed.
My main interest is in separating my application logic from my template / user-interface, i.e. MVC (Model + View + Controller). A lot of the code we develop gets reused a lot, as we develop websites for estate agents. Currently all 300 sites have a copy of it's own application logic. So if a bug appears, we have to fix it in 300 instances of code.
I want to revamp the code so its all central with also a central database, but each agent has their own website template, which draws information related to their site from the central database using centralized code. One instance of code will make the project easier and allow us to create a portal as well as maintain the code, supply bug fixes and develop add-ons across the board. Also one database is used across multiple agents where their data is separated by means of a unique agent ID.
Basically I need a RAD strategy, and at current, CodeIgniter looks the best for me. PEAR and Zend Framework are too expansive, I do suppose it has been around for a while so more code has been developed.
This is what I use, very simple way to separate logic and no added baggage. Essentially you will create a 'templates' folder, then you will have two pages, for example index.php will have a corresponding templates/index-tpl.php, all display logic gets put into the template, and business into the index.php.
Code: Select all
<?
/**
* set() - sets a variable to be used in the template
* display() - includes the template file (FILENAME-tpl.php)
*/
class templates{
function set($name, $value){
$this->vars[$name] = $value;
}
function display(){
if(isset($this->vars)){
extract($this->vars);
}
$page = basename($_SERVER['SCRIPT_FILENAME']);
$page = str_replace('.php','', $page);
$template = $page . '-tpl.php';
return include('templates/'.$template);
}
}
?>- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
As for a template engine, use XSLT. It forces you to marshal your data into a content neutral format (XML/DOM) and then lets you convert it to HTML or whatever else you want. Template-based solutions still don't do a good enough job of enforcing business/presentation logic separation without strong developer discipline.
I've had great successes with Template Lite. Love it.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.