alveby / atrium-language
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
Requires
- php: ^8.3
- ext-mbstring: *
- brick/math: ^1.0
- illuminate/support: ^13.0
Requires (Dev)
- alveby/atrium: ^0.5
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.5
Suggests
- alveby/atrium: Lets modules add formula functions through the hook registry atrium.language.functions
Provides
None
Conflicts
None
Replaces
None
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