A Twig to PHTML transpiler that converts Twig template syntax into PHP (PHTML) code. Version 0.3.4 is the current stable release, with infrequent updates. It differs from alternatives like twig2php by focusing on direct transpilation without runtime dependencies. Designed for build-time use in PHP projects migrating from Twig to native PHP templates. Supports basic Twig constructs like variable output, loops, and conditionals.
npm install twig-to-phtmlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Transpiler instance and transpiles a simple Twig variable into PHTML.
Check the documentation for supported tags and filters. Use only basic syntax.
Monitor the GitHub repository for breaking changes and new releases.
Always review generated PHTML code before using in production.
Use import { Transpiler } from 'twig-to-phtml'Run npm install --save-dev twig-to-phtml
Call transpiler.transpile(twigString) to convert.
No dependency data recorded yet.