Search by

alveby / atrium-language

xiregroup

Atrium's own language: a typed tree shared by formulas, rules and plugins, an Excel-like formula parser in Russian and English, and an interpreter with limits

Package info

github.com/AlveBy/atrium-language

Homepage

Issues

pkg:composer/alveby/atrium-language

Statistics

Installs: 6

Dependents: 2

Suggesters: 0

Stars: 0

v0.5.0 2026-12-03 17:18 UTC

This package is auto-updated.

Last update: 2026-12-04 08:18:42 UTC


README

The first part of Atrium's own language: formulas written the way a spreadsheet writes them, in English or Russian, parsed into a typed tree and run by an interpreter with limits, with a script that works the same formulas out in the browser. A formula reads only the fields it is given, calls only registered functions, never becomes PHP and cannot hang a page. Errors carry a line and a column and are written for people, in the 15 admin languages.

Install

composer require alveby/atrium-language

It is a library, not a module: no tables, no menu, nothing to switch on.

Use

use Atrium\Language\Context;
use Atrium\Language\Formula;
use Atrium\Language\Schema;

$schema = Schema::make()
    ->number('amount', 'Amount', 'Сумма')
    ->text('status', 'Status', 'Статус');

$formula = Formula::parse('IF(Amount > 1000; "big"; "small")');
$context = Context::make($schema, ['amount' => 1500, 'status' => 'new']);

$check = $formula->check($context);      // $check->passes(), $check->messages('en'), $check->type
$result = $formula->evaluate($context);  // (string) $result->value === 'big'

Syntax, types, functions, limits and how a plugin adds a function: docs/language.md.

Tests

From the repository root:

vendor/bin/phpunit packages/language/tests

Contributing

This package lives in packages/language of AlveBy/atrium. Issues and pull requests go there.

License

MIT