PHPackages                             eventjet/ausdruck - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. eventjet/ausdruck

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eventjet/ausdruck
=================

A small expression engine for PHP

0.2.4(6mo ago)010.2k—0%[5 issues](https://github.com/eventjet/ausdruck/issues)[5 PRs](https://github.com/eventjet/ausdruck/pulls)MITPHPPHP &gt;=8.3

Since Oct 6Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/eventjet/ausdruck)[ Packagist](https://packagist.org/packages/eventjet/ausdruck)[ RSS](/packages/eventjet-ausdruck/feed)WikiDiscussions 0.2.x Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (26)Used By (0)

Ausdruck
========

[](#ausdruck)

A small expression engine for PHP.

Quick start
-----------

[](#quick-start)

```
composer require eventjet/ausdruck

```

```
use Eventjet\Ausdruck\Parser\ExpressionParser;
use Eventjet\Ausdruck\Parser\Types;
use Eventjet\Ausdruck\Type;

$expression = ExpressionParser::parse(
    'joe:MyPersonType.name:string()',
    new Types(['MyPersonType' => Type::listOf(Type::string())]),
);
$scope = new Scope(
    // Passing values to the expression
    ['joe' => ['joe']],
    // Custom function definitions
    ['name' => static fn (array $person): string => $person[0]],
);
$name = $expression->evaluate($scope);
assert($name === 'Joe');
```

Documentation
-------------

[](#documentation)

### Accessing scope variables

[](#accessing-scope-variables)

Syntax: `varName:type`

Scope variables are passed from PHP when it calls `evaluate()` on the expression:

```
use Eventjet\Ausdruck\Parser\ExpressionParser;
use Eventjet\Ausdruck\Scope;

$x = ExpressionParser::parse('foo:int')
    ->evaluate(new Scope(['foo' => 123]));
assert($x === 123);
```

#### Examples

[](#examples)

`foo:int`, `foo:list`

See [Types](#types)

### Literals

[](#literals)

- `123`: Integer
- `"foo"`: String
- `1.23`: Float
- `[1, myInt:int, 3]`: List of integers
- `["foo", myString:string, "bar"]`: List of strings

### Operators

[](#operators)

Both operands must be of the same type.

OperatorDescriptionExampleNote`===`Equality`foo:string === "bar"``-`Subtraction`foo:int - bar:int`Operands must be of type `int` or `float``>`Greater than`foo:int > bar:int`Operands must be of type `int` or `float``||`Logical OR`foo:bool || bar:bool`Operands must be of type `bool`&amp;&amp;Logical AND`foo:bool && bar:bool`Operands must be of type `bool`Where's the rest? We're implementing more as we need them.

### Types

[](#types)

The following types are supported:

- `int`: Integer
- `string`: String
- `bool`: Boolean
- `float`: Floating point number
- `list`: List of type T
- `map`: Map with key type K and value type V
- Any other type will be treated as an alias that you will have to provide when parsing the expression: ```
    use Eventjet\Ausdruck\Parser\ExpressionParser;
    use Eventjet\Ausdruck\Type;

    ExpressionParser::parse('foo:MyType', ['MyType' => Type::alias(Type::listOf(Type::string()))]);
    ```

### Functions

[](#functions)

Syntax: `target.functionName:returnType(arg1, arg2, ...)`

The target can be any expression. It will be passed as the first argument to the function.

#### Example

[](#example)

`haystack:list.contains:bool(needle:string)`

#### Built-In Functions

[](#built-in-functions)

FunctionDescriptionExample`count`Returns the number of elements in a list`foo:list.count:int()``contains`Returns whether a list contains a value`foo:list.contains:bool("bar")``head`Returns the first element of a list as an `Option``foo:list.head:Option()``isSome`Takes an Option and returns whether it is `Some``foo:Option.isSome:bool()``map`Returns a new list with the results of applying a [function](#lambdas)`foo:list.map:list(|i| i:int - 2)``some`Returns whether any element matches a [predicate](#lambdas)`foo:list.some:bool(|item| item:int > 5)``substr`Returns a substring of a string`foo:string.substr:string(0, 5)``tail`Returns all elements of a list except the first`foo:list.tail:list()``take`Returns the first n elements of a list`foo:list.take:list(5)``unique`Returns a list with duplicate elements removed`foo:list.unique:list()`#### Custom Functions

[](#custom-functions)

You can pass custom functions along with the scope variables:

```
use Eventjet\Ausdruck\Parser\ExpressionParser;use Eventjet\Ausdruck\Scope;

$scope = new Scope(
    ['foo' => 'My secret'],
    ['mask' => fn (string $str, string $mask) => str_repeat($mask, strlen($str))]
);
$result = ExpressionParser::parse('foo:string.mask("x")')->evaluate($scope);
assert($result === 'xxxxxxxxx');
```

The target of the function/method call (`foo:string` in the example above) will be passed as the first argument to the function.

### Lambdas

[](#lambdas)

Syntax: `|arg1, arg2, ... | expression`

To access an argument, you must specify its type, just like when accessing scope variables.

#### Example

[](#example-1)

`|item| item:int > 5`

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance70

Regular maintenance activity

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.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 ~57 days

Recently: every ~102 days

Total

14

Last Release

205d ago

PHP version history (3 changes)v0.1.0PHP &gt;=8.2

0.1.1PHP &gt;=8.1

0.2.3PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf84c6852b03fde91d73c1c04b6dabe5d47167d4994a6cf40c11e5cfd18d07e7?d=identicon)[trinet](/maintainers/trinet)

---

Top Contributors

[![MidnightDesign](https://avatars.githubusercontent.com/u/743172?v=4)](https://github.com/MidnightDesign "MidnightDesign (39 commits)")[![rieschl](https://avatars.githubusercontent.com/u/3321556?v=4)](https://github.com/rieschl "rieschl (1 commits)")

---

Tags

expressionenginehacktoberfestphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/eventjet-ausdruck/health.svg)

```
[![Health](https://phpackages.com/badges/eventjet-ausdruck/health.svg)](https://phpackages.com/packages/eventjet-ausdruck)
```

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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