Search for a command to run...
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:
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.