PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 17th, 2012, 10:10 PM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is offline
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,600 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 7 m 45 sec
Reputation Power: 70
Best templating engine for php

This is one of those topics that I see so many different opinions on!

I use Codeigniter now and I am doing a research which templating engine suits the best. I haven't found 2 post that have the same opinion! Some say smarty is gold some say stay away from it. Same with Rain tpl, twig,...

I was wondering if you could write your comments on this.

Thanks

Reply With Quote
  #2  
Old November 18th, 2012, 07:44 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,864 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 5 m 57 sec
Reputation Power: 813
Hi,

there is no "best template engine". Some are more user friendly than others, some are faster, some use less memory, some are simpler etc.

I'd go with one of the mainstream engines (Smarty, Twig, ...) that have been proven to work and then simply choose the one you like best. If performance is very important to you, you might also google for benchmarks.

Reply With Quote
  #3  
Old November 18th, 2012, 06:44 PM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is offline
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,600 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 7 m 45 sec
Reputation Power: 70
Quote:
Originally Posted by Jacques1
Hi,

there is no "best template engine". Some are more user friendly than others, some are faster, some use less memory, some are simpler etc.

I'd go with one of the mainstream engines (Smarty, Twig, ...) that have been proven to work and then simply choose the one you like best. If performance is very important to you, you might also google for benchmarks.
Thanks I made up my mind. I am going to learn Smarty.
Benefits:
- It seems to be important to large companies in case I want to look for job in future,
- It is another skill,
- And it is always good to learn something new,
- It is well known ( as you mentioned),

Saying that I still think the messy code in inevitable.
PHP Code:
{foreach $foo as $bar}
  <
a href="{$bar.zig}">{$bar.zag}</a>
  <
a href="{$bar.zig2}">{$bar.zag2}</a>
  <
a href="{$bar.zig3}">{$bar.zag3}</a>
{
foreachelse}

//OR
{foreach $foo as $bar}
  {if 
$bar@iteration is div by 4}
    </
tr><tr>
  {/if}
  <
td>{$bar}</td>
{/foreach}
  
There were no rows found.
{/foreach} 

Reply With Quote
  #4  
Old November 18th, 2012, 07:11 PM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,864 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 5 m 57 sec
Reputation Power: 813
Quote:
Originally Posted by zxcvbnm
Thanks I made up my mind. I am going to learn Smarty.


Sounds good.



Quote:
Originally Posted by zxcvbnm
Saying that I still think the messy code in inevitable.


Well, I don't find this example all that terrible. And you'll rarely need stuff like "... @iteration is div by ...", since the structure should already be given by the model.

But sure, you'll never be able to avoid "messy" templates completely. It simply comes with complexity.

Reply With Quote
  #5  
Old November 20th, 2012, 04:07 AM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is offline
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,600 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 7 m 45 sec
Reputation Power: 70
Quote:
Originally Posted by Jacques1
Sounds good.
Well, I don't find this example all that terrible. And you'll rarely need stuff like "... @iteration is div by ...", since the structure should already be given by the model.
But sure, you'll never be able to avoid "messy" templates completely. It simply comes with complexity.
Jacques1! I got Smarty working. I don't like it at all! Now I see how much I like the idea of using php tags within html code! Maybe I am just new to this! This is strange that everyone uses template engines. I know we talked about this but I still think the messy code is inevitable and the benefits are nothing compared to the headache. Or maybe I am missing the whole point.
PHP Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class 
Members_model extends CI_Model
    
{
        function 
list_members()
            {
                
$query $this->db->query("SELECT * FROM members");
                return 
$query->result();
            }
    } 
PHP Code:
public function list_members()
        {
            
$this->load->model('members_model');
            
$members $this->members_model->list_members();
            
$this->smarty->assign("members"$members);
            
$this->smarty->view('index');
     } 
Code:
{section name=co loop=$members}
 {$members[co]->email}<br />
{/section}

Last edited by zxcvbnm : November 20th, 2012 at 04:56 AM.

Reply With Quote
  #6  
Old November 20th, 2012, 04:57 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,864 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 5 m 57 sec
Reputation Power: 813
Um, you've used Smarty for two days, and you've already come to the conclusion that template engines in general are bad?

First of all, you've picked the most cumbersome solution. Simply make a foreach:

Code:
{foreach $members as $member}
	{$member->email}<br />
{/foreach}


Secondly, if you don't like Smarty, then simply try another engine. Wasn't that the whole point of this thread?

I mean, nobody forces you to use template engines. If you want to use the good old PHP tags, simply do it. But making a decision based on a quick look and "this looks strange" doesn't sound like a good idea.

Reply With Quote
  #7  
Old November 20th, 2012, 05:33 PM
Nanomech's Avatar
Nanomech Nanomech is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Location: The Pleiades
Posts: 196 Nanomech User rank is Sergeant (500 - 2000 Reputation Level)Nanomech User rank is Sergeant (500 - 2000 Reputation Level)Nanomech User rank is Sergeant (500 - 2000 Reputation Level)Nanomech User rank is Sergeant (500 - 2000 Reputation Level)Nanomech User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 23 h 52 m 41 sec
Reputation Power: 7
Send a message via Skype to Nanomech
To be honest, I'm using a template which I found from watching a couple of youtube videos. This guys setup works really really well with what I am doing. It's all about using one main index.php page to display all your HTML template pages. Such a neat system.

Check this out: http://www.youtube.com/user/betterphp
Browse through his videos and you will come across templates which he writes the code for in his videos. He explains things pretty well also.

Hope this helps.

Regards.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Best templating engine for php

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap