views:

248

answers:

5

I came upon Smarty which is a template engine. But there are also the Zend, CakePHP frameworks. Is Smarty like Zend, or are they completely different? Smarty just separates logic from display - is this similar to a framework like Zend?

+10  A: 

Smarty is a template engine while Zend is a complete php framework.

Smarty

Smarty is a web template system written in PHP. Smarty is primarily promoted as a tool for separation of concerns, which is a common design strategy for certain kinds of applications.[1][2]

Smarty generates web content by the placement of special Smarty tags within a document. These tags are processed and substituted with other code.

Tags are directives for Smarty that are enclosed by template delimiters. These directives can be variables, denoted by a dollar sign ($), functions, logical or loop statements. Smarty allows PHP programmers to define custom functions that can be accessed using Smarty tags.

Smarty is intended to simplify compartmentalization, allowing the presentation of a web page to change separately from the back-end. Ideally, this eases the costs and efforts associated with software maintenance. Under successful application of this development strategy, designers are shielded from the back-end coding, and PHP programmers are shielded from the presentation coding.

Zend

ZF is a use-at-will framework. There is no single development paradigm or pattern that all Zend Framework users must follow, although ZF does provide components for the MVC, Table Data Gateway, and Row Data Gateway design patterns. Zend Framework provides individual components for many other common requirements in web application development.[1]

Zend Framework also seeks to promote web development best practices in the PHP community; conventions are not as commonly used in ZF as in many other frameworks, rather suggestions are put forth by setting reasonable defaults that can be overridden for each ZF application’s specific requirements.[4]

Sarfraz
So Smarty is more 'basic' and just separates your code into logic/display. While Zend gives you the whole framework, functions and stuff. ?
jpjp
@jpjp: That's right :)
Sarfraz
To repeat what he said. Smarty is just a template engine. Zend is a complete php framework. Zend has a lot of components that you can plug into and develop with, including a template engine, access control list, ftp, etc. Think of Zend like a library of tools while Smarty is just one tool.
Foxtrot
thank you, that clears up a lot!
jpjp
@jpjp: You are welcome...
Sarfraz
+2  A: 

Zend is an open source web application framework.

Smarty is a web template system.

Check Zend and Smarty.

Incognito
A: 

Zend is a JIT implementation of the PHP language. It processes all of your PHP code and compiles it into machine code for execution. Caching frameworks such as APC provide opcode caching to improve performance.

Smarty is a template language implemented in PHP. It separates business logic and presentation.

Zend -> PHP -> Smarty -> Your Website

Will Bickford
I think the OP meant Zend Framework, not the underlying Zend Engine :-)
richsage
Yeah reading the other answers that is pretty clear. Oh well!
Will Bickford
+1  A: 

A template engine (Smarty) simply provides a method to separate the display from the actual code.

A framework (Zend, CakePHP, Drupal etc) provides essentially a language extension on top of PHP. You then use this 'language' to write your site. It provides you with methods to achieve more complex tasks easily (more so at least). It generally helps with things such as database access, security, i18n/l10n, caching, templating, etc.

Dan McGrath
that's a good description! So with a framework, they do all the "dirty" work and you just use the functions? so does a framework have like functions that can help you with validations and stuff?
jpjp
Yup. For example have a look at http://book.cakephp.org/view/125/Data-Validation
Dan McGrath
A: 

You're mixing somewhat those concepts.

A template engine does not separate the logic from display but it is a means to achieve that.

A framework, on the other hand, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality [Wikipedia]. Some frameworks, including the Zend Framework, provide with an implementation of the MVC (Model View Controller) architectural pattern, making it straightforward to isolate the persistence, the logic and the presentation layers.

nuqqsa