PHPackages                             uuf6429/expression-language-tplstring - 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. uuf6429/expression-language-tplstring

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

uuf6429/expression-language-tplstring
=====================================

Template String support for Symfony Expression Language

2.0.0(3y ago)06.0k1MITPHPPHP ^7 || ^8

Since Jul 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/uuf6429/expression-language-tplstring)[ Packagist](https://packagist.org/packages/uuf6429/expression-language-tplstring)[ Docs](https://github.com/uuf6429/expressions-language-tplstring)[ RSS](/packages/uuf6429-expression-language-tplstring/feed)WikiDiscussions main Synced 1mo ago

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

🪡 Template Strings
==================

[](#-template-strings)

for Symfony Expression Language (4-6)

[![CI](https://github.com/uuf6429/expression-language-tplstring/actions/workflows/ci.yml/badge.svg)](https://github.com/uuf6429/expression-language-tplstring/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/64ac34904f5598214da5180e0720bf7baf7633399ba81beb4f041cbd4af3381e/68747470733a2f2f636f6465636f762e696f2f67682f757566363432392f65787072657373696f6e2d6c616e67756167652d74706c737472696e672f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/uuf6429/expression-language-tplstring)[![Minimum PHP Version](https://camo.githubusercontent.com/92c7dc516007c205142490e0c6ae267cab403bebcaf787a437ab9b80dbf299f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d25354537253230253743253230253545382d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/b1d9e94ec75783931141c741c3ee72dfa6c0586bf990ce83268a6a7ff5d60011/68747470733a2f2f706f7365722e707567782e6f72672f757566363432392f65787072657373696f6e2d6c616e67756167652d74706c737472696e672f6c6963656e7365)](https://github.com/uuf6429/expression-language-tplstring/blob/main/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/9d7b88c24cd7eea1c4567c2f8b19362fa054351ae9b2032cb49bd6e4791f4339/68747470733a2f2f706f7365722e707567782e6f72672f757566363432392f65787072657373696f6e2d6c616e67756167652d74706c737472696e672f76657273696f6e)](https://packagist.org/packages/uuf6429/expression-language-tplstring)[![Latest Unstable Version](https://camo.githubusercontent.com/d13728a19755d2fdec202125c28c1ea5bcaafa933637b5510e1a99586cf6dd38/68747470733a2f2f706f7365722e707567782e6f72672f757566363432392f65787072657373696f6e2d6c616e67756167652d74706c737472696e672f762f756e737461626c65)](https://packagist.org/packages/uuf6429/expression-language-tplstring)

> **What looks like a dot, a cross and a wave, and does the same thing?**
>
> It's the concatenation operator, of course!
>
> PHP uses a dot/period (`.`), many languages including javascript use `+`, whereas [Symfony Expression Language](https://github.com/symfony/expression-language) uses the tilde (`~`).

This library provides a translation layer on top of Expression Language that converts template strings in ES6 format\* to valid expression. While an updated Expression Language subclass is provided for convenience, you don't have to use it, and you can use the provided trait instead.

*\* only ES6 string interpolation (with any expressions and nesting) is supported; f.e. tagged templates are not.*

🔌 Installation
--------------

[](#-installation)

As always, the recommended and easiest way to install this library is through [Composer](https://getcomposer.org/):

```
composer require "uuf6429/expression-language-tplstring"
```

🚀 Usage
-------

[](#-usage)

If you do not plan on extending Symfony Expression Language class, you can use the provided drop-in:

```
$el = new \uuf6429\ExpressionLanguage\ExpressionLanguageWithTplStr();
$el->evaluate('`hello ${name}!`', ['name'=>'mars']); // => hello mars!
```

Otherwise, you can subclass the desired Expression Language class and `use` the provided trait:

```
class MyEL extends \uuf6429\ExpressionLanguage\ExpressionLanguageWithArrowFunc
{
    use \uuf6429\ExpressionLanguage\TemplateStringTranslatorTrait;

    public function compile($expression, array $names = [])
    {
        if (!$expression instanceof \Symfony\Component\ExpressionLanguage\ParsedExpression) {
            $expression = $this->translateTplToEl($expression);
        }

        return parent::compile($expression, $names);
    }

    public function evaluate($expression, array $values = [])
    {
        if (!$expression instanceof \Symfony\Component\ExpressionLanguage\ParsedExpression) {
            $expression = $this->translateTplToEl($expression);
        }

        return parent::evaluate($expression, $values);
    }
}

$el = new MyEL();
$el->evaluate(
    'users.map((user) -> { `hello ${user.name}!` }).join(` `)',
    [
        'users' => new \Illuminate\Support\Collection([
            (object)['name' => 'John', 'surname' => 'Doe'],
            (object)['name' => 'Jane', 'surname' => 'Roe'],
        ])
    ]
); // => hello John! hello Jane!
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Every ~159 days

Total

2

Last Release

1234d ago

Major Versions

1.0.0 → 2.0.02022-12-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/450767af6ef832ad662c169bf718d6d25c025c08b2d91b810959d190bccebba1?d=identicon)[uuf6429](/maintainers/uuf6429)

---

Top Contributors

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

---

Tags

expression-languagephpsymfonysyntaxtemplate-stringsuuf6429symfonystringlanguagetemplateexpressionDSLuuf6429

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uuf6429-expression-language-tplstring/health.svg)

```
[![Health](https://phpackages.com/badges/uuf6429-expression-language-tplstring/health.svg)](https://phpackages.com/packages/uuf6429-expression-language-tplstring)
```

PHPackages © 2026

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