 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Sean Coates' Blog: PHP as a templating language
by Chris Cornutt May 15, 2012 @ 10:58:37
In this new post to his blog Sean Coates talks about PHP as a templating language and why he (and Gimmebar) have decided to go another, more frontend-based direction.
For many years, I was a supporter of using PHP as a templating language to render HTML. However, I really don't buy into the idea of adding an additional abstraction layer on top of PHP, such as Smarty (and many others). In the past year or so, I've come to the realization that even PHP itself is no longer ideally suited to function as the templating engine of current web applications - at least not as the primary templating engine for such apps.
His reasoning is pretty simple - more and more web applications are becoming less and less server-driven. When building applications (and APIs) you don't know how the data will be consumed, so your frontend has to be agnostic. So, what's his current alternative of choice? The Mustache templating framework provides a simple way to create reusable templates (along with the compatible Handlebars Javascript library).
voice your opinion now!
templating language smarty mustache handlebars javascript api
Smashing Magazine: Getting Started With PHP Templating
by Chris Cornutt October 18, 2011 @ 09:15:49
On the Smashing Magazine site today there's a new post introducing you to templating in PHP applications. They cover both the creation of a simple, custom templating library as well as using a more widely known too - Twig.
In this article, we'll cover how to separate the view of your PHP application from its other components. We'll look at why using such an architecture is useful and what tools we can use to accomplish this. [...] To fully benefit from this article, you should already know how to write and run your own PHP scripts on a Web server (i.e. using Apache).
They start with the very basics of templating, mostly pointing out how it reduces the dependency of having layout code directly in your application's logic. It makes things easier to reuse and makes for better code structure in the long run. They mention other templating engines like Smarty, PHPTAL and Twig, but focus in on the last for their code samples. They show basic templating, making reusable templates, applying filters and working with simple control structures.
voice your opinion now!
templating tutorial introduction twig smarty phptal
PHPBuilder.com: 5 Popular PHP Template Engines Worth Checking Out
by Chris Cornutt April 08, 2011 @ 13:23:40
On PHPBuilder.com today there's a new article looking at five PHP templating engines that they think are worth a look for use in your next project (or maybe in a current one).
In this article I'll introduce five of PHP's most popular templating engines, providing you with a basis for continuing your own investigations. Keep in mind however that this list is by no means definitive; if you have experience using a templating engine not discussed here, please tell us about it in the comments!
The five template engines the author chose to spotlight are:
- Smarty
- Dwoo
- Twig
- Savant3
- PHPTal
Each comes with a description of its major features and a code snippet or two showing it in use.
voice your opinion now!
template engine twig dwoo savant3 smarty phptal
Gonzalo Ayuso's Blog: PHP Template Engine Comparison
by Chris Cornutt January 17, 2011 @ 08:16:37
In a new post to his blog Gonzalo Ayuso has put together a comparison of a few PHP templating alternatives out there developers can use to further separate the view logic from the main parts of their application.
Template engines has a lot of features but I normally only use a few of them and the other features very seldom. In this performance test I will check the same features under different template engines to see the syntax differences and the performance. The template engines selected for the test are Smarty, Twig and Haanga.
He does some testing with each, creating a basic template to loop and create a basic table (template code and PHP code included) as well as an example using template inheritance with each. The reports of his tests are shared at the end with stats for memory used and execution time for both the normal templates and the inherited versions - but you'll have to check out the post for those results.
voice your opinion now!
template engine compare benchmark twig haanga smarty
Shameer's Blog: An Introduction to Smarty 3
by Chris Cornutt October 07, 2010 @ 11:15:49
On his blog today Shameer has posted an introduction to Smarty 3, the upcoming version of the popular PHP-based templating engine. He talks about some of the improvements that have been made since version 2 in several categories including:
- plugins
- file structure
- variable scope/storage
- template inheritance
The Smarty 3 API (as of beta 8 ) has been refactored to a syntax geared for consistency and modularity. The Smarty 2 API syntax is still supported, butwill throw a deprecation notice. You can disable the notices, but it is highly recommended to adjust your syntax to Smarty 3, as the Smarty 2 syntax must run through an extra rerouting wrapper.
Code snippets are included for things like the new templating syntax, object handling, assigning variables and working with the inheritance now available.
voice your opinion now!
smarty version introduction tutorial feature
NETTUTS.com: Introduction to the Smarty Templating Framework
by Chris Cornutt September 15, 2010 @ 10:08:35
On NETTUTS.com today there's a new tutorial introducing you to one of the more well-established templating tools for PHP-based applications - Smarty. It provides abstraction between your data and the output of the site, making is simpler to maintain in the long run.
Smarty is a PHP-based templating engine/framework. It allows you to further separate your business logic from its visualization, by removing as much PHP code as possible away from your views. Some developers and frameworks prefer not to use a templating engine, others do prefer them to using plain PHP in your views. Both points of view can be argued, and in the end, it's mostly a matter of taste. Anyway, it's never a bad idea to try it out before deciding not to use it, and that's what this tutorial is about: trying out the Smarty Templating Framework.
They introduce it in a series of five steps (well, six):
- What To Expect
- Setting Up The Project
- Creating The SMTemplate Class
- Assigning and Formatting Variables
- Working With a Layout
- Creating Your Own Modifiers
Each of these comes with code examples and full descriptions so that, by the end of the tutorial, you'll end up with a full "Hello World" template system. The modifiers let you augment the base Smarty functionality to handle custom types and make handling the data even simpler.
voice your opinion now!
smarty template framework tutorial introduction
Ivo Jansch's Blog: PHP as a template language
by Chris Cornutt February 15, 2010 @ 08:12:04
Ivo Jansch has a recent post to his blog talking about one of the great debates in the world of PHP - is the language by itself a good templating language (versus using something like Smarty)?
I think I've said it before. The tool you use should depend on the job you're trying to do. So to say that Smarty is wrong just because it is, does not feel right. I agree that in many cases PHP can be used as a template language just fine, but there are situations where a Smarty template (or any other templating engine) is just that more pleasant.
He's comparing them on aesthetics alone, showing two snippets of code - one templated via PHP and the other in the format that Smarty uses to generate a simple chunk of XML. For more examples of the Smarty format, check out their documentation.
voice your opinion now!
template language opinion smarty
PHPBuilder.com: Build an MVC Framework with PHP
by Chris Cornutt December 18, 2009 @ 07:50:52
On PHPBuilder.com today there's a new tutorial that walks you through the process of creating a simple MVC framework in PHP based on Smarty, PostgreSQL and the PEAR XML_Serializer package.
PHP now enables you to build robust, manageable, and beautiful enterprise web applications. The best way to do that is to divide the application into three components: model, view, and controller. In other words, you need to separate the presentation, the database, and the business logic from each other. The most common approach for achieving this design goal is to adhere to a strict Model-View-Controller (MVC) framework.
He uses the example of creating an application (a feed reader) to show how the parts of the MVC will fit together as a whole. You won't find any code examples in the article, just an explanation of how everything works together. You can, however, dowload the source and follow along.
voice your opinion now!
mvc framework tutorial smarty postgresql pear
|
Community Events
Don't see your event here? Let us know!
|