Download the PHP package oxygensuite/php-ast without Composer

On this page you can find all versions of the php package oxygensuite/php-ast. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-ast

oxygensuite/php-ast

A lightweight formula engine for PHP built on an Abstract Syntax Tree (AST). Parse, evaluate, and transform expressions with support for variables, functions, wildcards, and operator precedence.

Requirements

Installation

Quick Start

Variables

Variables use dot-notation for nested property access. Types are preserved (string, int, float, bool, null, array).

Syntax Resolves to
uid $data['uid']
lines.0.quantity $data['lines'][0]['quantity']
a.b.c $data['a']['b']['c']

Variables can be used directly in expressions:

Wildcards

The * wildcard extracts values across all items in an array.

Operators

Listed from highest to lowest precedence:

Precedence Operators Description
1 ** Exponentiation
2 * / % Multiplication, division, modulo
3 + - Addition, subtraction
4 == != < > <= >= <=> Comparison
5 && Logical AND
6 \|\| Logical OR
7 ?? ?: Null coalescing, elvis

Parentheses override precedence: (a + b) * c.

Functions

All functions use semicolons (;) as argument separators.

Aggregation

Function Description Example
SUM(values) Sum of numeric values SUM(lines.*.quantity)
AVG(values) Average AVG(lines.*.unit_price)
MIN(values) Minimum value MIN(lines.*.unit_price)
MAX(values) Maximum value MAX(lines.*.quantity)
COUNT(values) Number of elements COUNT(lines.*.quantity)

Rounding

Function Description Example
ROUND(value; precision) Round to precision decimals ROUND(10.567; 2)10.57
CEIL(value) Round up CEIL(10.1)11
FLOOR(value) Round down FLOOR(10.9)10

Array Manipulation

Function Description Example
PLUCK(array; "key") Extract column from array of objects PLUCK(lines; "quantity")
FLAT(array; depth) Flatten nested arrays (default depth: 1) FLAT([[1,2],[3,[4,5]]]; 2)
MAP(array; expr) Apply expression per item MAP(lines; quantity * unit_price)
FILTER(array; condition) Filter items by condition FILTER(lines; unit_price > 10)
GROUP(array; "key") Group items by key GROUP(lines; "tax_category")
SORT(array) Sort array SORT(lines.*.quantity)
JOIN(array; separator) Join into string JOIN(lines.*.quantity; ",")
FIRST(array) First element FIRST(lines)
LAST(array) Last element LAST(lines)

Conditional

Function Description Example
IF(cond; true_val; false_val) Conditional IF(quantity > 10; "bulk"; "single")
VALUE(array; "key") Get value by key VALUE(line; "quantity")

Composing Functions

Functions can be nested and combined with arithmetic:

Context Providers

For injecting external values (e.g., configuration, session data) into formula evaluation:

Context values take priority over data array values.

Custom Functions

Simple Function

Implement the Formula interface:

AST-Aware Function

For functions that need per-item evaluation (like MAP/FILTER), implement ASTFormula instead. It receives raw AST nodes so you can evaluate expressions against each item:

Caching

Parsed ASTs are automatically cached per evaluator instance (default: 1000 entries). Repeated evaluation of the same formula string skips parsing entirely.

Error Handling

Scenario Behavior
Missing variable Returns null
Division by zero Returns 0
Unknown function Throws RuntimeException
Invalid expression Throws RuntimeException
Recursion depth > 32 Throws RuntimeException

License

MIT


All versions of php-ast with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-ctype Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package oxygensuite/php-ast contains the following files

Loading the files please wait ...