Command Palette

Search for a command to run...

position in category
#11

Modern template engine for PHP that compiles templates into plain, optimized PHP code with minimal overhead. Designed for concise syntax, security by default, and extensibility so teams can keep presentation logic separate from application code.

Twig powers the Symfony ecosystem and is widely adopted across PHP applications that need safe templating. Unlike raw PHP or older engines, it enforces automatic output escaping and offers sandbox mode for evaluating untrusted user-supplied templates. Its flexible lexer and parser allow defining custom tags, filters, and domain-specific extensions.

Key features:

  • Automatic output escaping with HTML-safe defaults and fine-grained control
  • Sandbox mode for safely rendering user-modified or third-party templates
  • Template inheritance, blocks, and includes for reusable layouts
  • Custom tags, filters, and extensions via the lexer and parser
  • Concise syntax optimized for designers and developers

Adoption spans rendering views in Symfony, Craft CMS, Drupal, and other PHP frameworks, building email templates, generating HTML reports, and templating config files. Developers integrate Twig via Composer and benefit from IDE support and the official Twig certification for onboarding.

GitHub Repositories
59
-14.5%
Trending down this week
Removed in 10 repos