 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Derick Rethans' Blog: Twig extension
by Chris Cornutt November 21, 2011 @ 08:35:39
In a new post from Derick Rethans he talks about an extension version of Twig, the popular templating engine from the creators of the Symfony framework.
A while ago, Fabien asked me to have a look at porting one of Twig's slowest methods, TwigTemplate::getAttribute(), into a PHP extension. It is a complex method that does a lot of different checks and look-ups. Fabien's benchmarks showed that this method was responsible for quite a large amount of time. On top of that, it didn't seem that it could be optimised any further as PHP code itself.
He points to the twig-ext extension that's a reworked version of the "getAttribute" method from the tool and the performance gain (about 15%) it gives. Compiled templates will automatically call this new method in the extension. This update has already been merged into the main Twig repo.
voice your opinion now!
twig extension template language symfony speed
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
NetTuts.com: Rapid Application Prototyping in PHP Using a Micro Framework
by Chris Cornutt September 06, 2011 @ 09:56:57
On NetTuts.com today there's a new tutorial posted about using a microframework for prototyping an application you may not need a full stack framework to get running. Their examples are based on the Slim framework.
Let's face it: we all have great ideas for a web application. Whether you write them down on paper or remember them using your eidetic memory, there comes a point when you want test whether or not your idea is really viable. In this tutorial, we'll use a micro framework, a templating language and an ORM to rapidly develop an application prototype.
There's an introduction to help you get Slim, some extras, Twig templating and Paris and Idorm set up and working happily together. There's code included for bootstrapping the application, creating a few routes, building models and using them to pull data from the database. They also create an "admin" area for their sample blog application, building an "add article" form and protecting it with a simple login system. You can download the source if you'd like to see it all working together.
voice your opinion now!
microframework tutorial rapid prototype slim twig paris idiorm
Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 2)
by Chris Cornutt May 05, 2011 @ 13:11:25
On the Zend Developer Zone they've posted the second part of Vikram Vaswani's look at using the Twig templating engine in your PHP applications. In the first part of the series, he introduced the tool and got started with some simple examples. In this second part, he dives in deeper to some of the advanced features.
In this second and concluding segment, I'll look at some of Twig's other features, including such goodies as template inheritance, custom filters and caching. If you enjoyed the first part of this article, keep reading to find out more about what goes on under Twig's hood, and how you can add even more power and flexibility to your templates
He looks at template inheritance, parent blocks/child templates, data filtering, the tool's "compilation cache" and working with native plugins.
voice your opinion now!
twig template tutorial inheritance filter cache plugin
Ryan Mauger's Blog: Using Twig with Zend Framework
by Chris Cornutt May 05, 2011 @ 08:28:18
Ryan Mauger has written up a new post about an integration he's done using the Twig templating engine (from be Symfony community) with his Zend Framework application to make view handling simpler.
Mostly I thought [what Twig offered] were silly things that were not really needed unless you had a team of designers to work with, however, during my exploration, a couple of things occurred to me that I had not considered about templating systems before. One being the enforced separation of concerns they provide; you simply cannot do anything from inside them which you shouldn't be, keeping your presentation very very clean. The second, being that they're not all as terrible as Smarty.
He helps you get Twig installed (via PEAR chnnel) and includes the code for an application resource and the changes you'll need to make to your application.ini to get things working. He uses a base controller setup, so he shows how to introduce a "twig()" method into that to help with rendering. Finally, there's a sample class included that includes two actions, both using this "twig()" method to pas the output data through the twig interpreter and out to the view.
voice your opinion now!
twig templating tutorial zendframework example pear
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
Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 1)
by Chris Cornutt April 07, 2011 @ 12:44:43
On the Zend Developer Zone today there's a new tutorial from Vikram Vaswani about using the Twig templating engine in your application. It's part one of a series that introduces the library to you and includes examples of some of the most common templating logic.
Most PHP frameworks, including Zend Framework, Agavi, CakePHP and CodeIgniter, come with built-in templating to enable this separation. However, if you're not a big fan of frameworks, or if your project is small enough that you don't need the additional overhead, you can also consider using a standalone template engine to obtain the same benefits. A number of such engines exist - you've probably already heard of Smarty, Savant, Dwoo and others - and in this article, I'll introduce you to one I discovered rather recently, called Twig.
The Twig project gives you a framework-independent tool for creating simple (or complex, if you'd like) templates for the output of your site. He shows you how to get it installed (via PEAR) and provides some sample templates for things like:
- using conditionals (if/else/etc)
- looping
- working with arrays from PHP
- including other templates
- using included filtering on data
voice your opinion now!
tutorial twig templating introduction
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
|
Community Events
Don't see your event here? Let us know!
|