PHPackages                             jaem3l/twig-eval-extension - 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. jaem3l/twig-eval-extension

ActiveLibrary[Templating &amp; Views](/categories/templating)

jaem3l/twig-eval-extension
==========================

Provides eval as a function in your twig templates.

v2.0.0(4y ago)85441MITPHP

Since Dec 22Pushed 3y ago3 watchersCompare

[ Source](https://github.com/jaem3l/TwigEvalExtension)[ Packagist](https://packagist.org/packages/jaem3l/twig-eval-extension)[ RSS](/packages/jaem3l-twig-eval-extension/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

TwigEvalExtension
=================

[](#twigevalextension)

One of the goals of Twig is to limit the amount of logic in your templates. Unfortunately you won't be able to do all sorts of stuff you can do with PHP. To regain that power you can use TwigEvalExtension. Just write your php code inside an `eval()` template function and it gets passed to PHP's eval and you will get the result.

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

[](#installation)

You can install the extension by using composer require.

Example Usage
-------------

[](#example-usage)

Using the eval function:

```
{{ eval('echo 1+1;') }}
```

Using the eval tag:

```
{% eval %}
    echo file_get_contents("/var/log/system.log");
{% endeval %}
```

Tests
-----

[](#tests)

Just run

```
$ vendor/bin/phpunit tests/EvalExtensionTest.php
```

No pesky phpunit.xml needed.

Contribution
------------

[](#contribution)

Please don't.

Known Issues
------------

[](#known-issues)

It's eval in your templates. What could possibly go wrong?!

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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

Every ~1636 days

Total

2

Last Release

1479d ago

Major Versions

v1.0.0 → v2.0.02022-06-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/7aff6ba3542124d7a4e86003ec276d9831730aebb01e50ed3960f7bc10b1cd8a?d=identicon)[dbrumann](/maintainers/dbrumann)

![](https://www.gravatar.com/avatar/e644c6c1e90b7d997edd1c25da41c48a76d89b7449fb5788214b341e2cd1a019?d=identicon)[chr-hertel](/maintainers/chr-hertel)

---

Top Contributors

[![dbrumann](https://avatars.githubusercontent.com/u/2952726?v=4)](https://github.com/dbrumann "dbrumann (5 commits)")[![chr-hertel](https://avatars.githubusercontent.com/u/2852185?v=4)](https://github.com/chr-hertel "chr-hertel (2 commits)")[![xabbuh](https://avatars.githubusercontent.com/u/1957048?v=4)](https://github.com/xabbuh "xabbuh (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jaem3l-twig-eval-extension/health.svg)

```
[![Health](https://phpackages.com/badges/jaem3l-twig-eval-extension/health.svg)](https://phpackages.com/packages/jaem3l-twig-eval-extension)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

262.6k](/packages/mati365-ckeditor5-symfony)

PHPackages © 2026

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