Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Symfony2 Essentials

You're reading from   Symfony2 Essentials

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781784398767
Length 158 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

The Twig templating engine

When Symfony1 was created, the framework did not use any of existing template systems but relied on just the PHP as a template language. It had some advantages (that is, templates did not require any processing and were very fast), but wasn't too friendly for frontend developers. Also, PHP is a very verbose language and you need to write a lot of code to do some basic stuff such as checking a variable and determining whether it exists or is empty. Also, escaping variables requires some coding.

In Symfony2, a new templating engine, called Twig, was introduced. Twig was written with a few concepts in mind, such as:

  • Templating system is extensible: Developer may write their own extensions to it very easily.
  • Fast: The written template is compiled and processed, generating an optimized PHP code on the output.
  • More secure: It is much easier to make code secure using Twig with features such as auto-escape or sandboxing.
  • Optimized for frontend development: The Twig syntax...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image