PHPackages                             clawrock/magento2-twig-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. clawrock/magento2-twig-engine

ActiveMagento2-module[Templating &amp; Views](/categories/templating)

clawrock/magento2-twig-engine
=============================

Magento 2 Twig Template Engine

1.0.0(7y ago)1133OSL-3.0PHP

Since Jan 7Pushed 7y ago2 watchersCompare

[ Source](https://github.com/clawrock/magento2-twig-engine)[ Packagist](https://packagist.org/packages/clawrock/magento2-twig-engine)[ RSS](/packages/clawrock-magento2-twig-engine/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

[![Packagist](https://camo.githubusercontent.com/e06d6ef77343ad6101f4fa4703ab766e9882f1230c1f730fb0dafbba1caab236/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c6177726f636b2f6d6167656e746f322d747769672d656e67696e652e737667)](https://packagist.org/packages/clawrock/magento2-twig-engine)[![Packagist](https://camo.githubusercontent.com/b311f5b6c3cb22464d6b64c79a510979a35d2a55fe7b833815a300860224bb04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c6177726f636b2f6d6167656e746f322d747769672d656e67696e652e737667)](https://packagist.org/packages/clawrock/magento2-twig-engine)[![Build Status](https://camo.githubusercontent.com/b274a69a7a9feb35342bdea0eed3be932b7967b5fe1d8637c25056b89fa92e7f/68747470733a2f2f7472617669732d63692e6f72672f636c6177726f636b2f6d6167656e746f322d747769672d656e67696e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clawrock/magento2-twig-engine)[![Coverage Status](https://camo.githubusercontent.com/c21840c00888ea1f2eb352c02dbd5c95871f699252f243cf307e93fab52f17df/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636c6177726f636b2f6d6167656e746f322d747769672d656e67696e652f62616467652e737667)](https://coveralls.io/github/clawrock/magento2-twig-engine)

Magento 2 - Twig Template Engine
================================

[](#magento-2---twig-template-engine)

Module implementing Twig as Magento 2 template engine. It works with default .phtml templates as fallback.

Installation
------------

[](#installation)

1. Install module via composer `composer require clawrock/magento2-twig-engine`
2. Register module `php bin/magento setup:upgrade`

Compatibility
-------------

[](#compatibility)

- Magento 2.2 - 2.3
- PHP 7.0 - 7.2

Configuration
-------------

[](#configuration)

There is **no** `system.xml` file, because [Twig configuration](https://twig.symfony.com/doc/2.x/api.html#environment-options) should be only edited by developers.

### Auto resolve option

[](#auto-resolve-option)

This module can automatically look for twig files. For example if you want to use twig template in `Magento\Theme\Block\Html\Title` block just add file in `app/design/frontend/Vendor/theme/Magento_Theme/templates/html/title.html.twig`. If you disable auto resolve you will have to update each block template manually:

```

```

Auto resolve option works the same as Magento 2 template resolver. For example if your theme is Luma and template is `Magento_Theme::html/title.phtml` it will check possible paths in following order until first existing file:

```
vendor/magento/theme-frontend-luma/Magento_Theme/templates/html/title.html.twig
vendor/magento/theme-frontend-luma/Magento_Theme/templates/html/title.twig
vendor/magento/theme-frontend-luma/Magento_Theme/templates/html/title.phtml

vendor/magento/theme-frontend-blank/Magento_Theme/templates/html/title.html.twig
vendor/magento/theme-frontend-blank/Magento_Theme/templates/html/title.twig
vendor/magento/theme-frontend-blank/Magento_Theme/templates/html/title.phtml

vendor/magento/module-theme/view/frontend/templates/html/title.html.twig
vendor/magento/module-theme/view/frontend/templates/html/title.twig
vendor/magento/module-theme/view/frontend/templates/html/title.phtml

```

Extending
---------

[](#extending)

### Environment options override

[](#environment-options-override)

#### XML

[](#xml)

Create module dependent on ClawRock\_TwigEngine and override values in config.xml

#### Programmatically

[](#programmatically)

Create before plugin for EnvironmentFactory and modify $options argument.

### Create new Twig Extension

[](#create-new-twig-extension)

Create Extension class extending AbstractExtension or implementing ExtensionInterface and register it with `etc/twig.xml`.

Example: `ClawRock\TwigEngine\Twig\Extension\MagentoExtension`

[See Twig documentation](https://twig.symfony.com/doc/2.x/advanced.html#creating-an-extension).

**Important!**You can use Magento DI in Twig Extensions.

Resources
---------

[](#resources)

- [Twig](https://twig.symfony.com/)
- [Extensions](https://github.com/twigphp/Twig-extensions)
- [Online converter](https://phptotwig.com/)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2731d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19371023?v=4)[ClawRock](/maintainers/clawrock)[@clawrock](https://github.com/clawrock)

---

Top Contributors

[![makao](https://avatars.githubusercontent.com/u/690371?v=4)](https://github.com/makao "makao (7 commits)")

---

Tags

developmentenginemagentomagento2templatetemplatingtwig

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/clawrock-magento2-twig-engine/health.svg)

```
[![Health](https://phpackages.com/badges/clawrock-magento2-twig-engine/health.svg)](https://phpackages.com/packages/clawrock-magento2-twig-engine)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.4M1](/packages/fastly-magento2)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1010.0k22](/packages/loki-magento2-components)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
